Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions website_sale_slides_order_line_link/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_sale_slides_order_line_link
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-01-30 10:53+0000\n"
"PO-Revision-Date: 2026-01-30 11:56+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.4.2\n"

#. module: website_sale_slides_order_line_link
#. odoo-python
#: code:addons/website_sale_slides_order_line_link/models/sale_order.py:0
#, python-format
msgid ""
"<p>Your registrations for the course <strong>%(course_name)s</strong> have "
"been increased by <strong>%(added_qty)s registration(s)</strong>.</p><p>You "
"now have a total of <strong>%(available_registrations)s</strong> "
"registration(s) purchased, of which <strong>%(used_registrations)s</strong> "
"have already been used and <strong>%(remaining_registrations)s</strong> are "
"still available.</p>"
msgstr ""
"<p>Sus inscripciones para el curso <strong>%(course_name)s</strong> se han "
"incrementado en <strong>%(added_qty)s inscripción(es)</strong>.</p><p>Ahora "
"dispone de un total de <strong>%(available_registrations)s</strong> "
"inscripción(es) adquiridas, de las cuales <strong>%(used_registrations)s</"
"strong> ya se han utilizado y <strong>%(remaining_registrations)s</strong> "
"siguen disponibles.</p>"

#. module: website_sale_slides_order_line_link
#: model:ir.model,name:website_sale_slides_order_line_link.model_slide_channel_partner
msgid "Channel / Partners (Members)"
msgstr ""

#. module: website_sale_slides_order_line_link
#. odoo-python
#: code:addons/website_sale_slides_order_line_link/models/sale_order.py:0
#, python-format
msgid "Course Registrations Added: %s"
msgstr "Inscripciones añadidas al curso: %s"

#. module: website_sale_slides_order_line_link
#: model:ir.model.fields,field_description:website_sale_slides_order_line_link.field_slide_channel_partner__sale_order_line_ids
msgid "Sale Order Lines"
msgstr "Líneas de pedido"

#. module: website_sale_slides_order_line_link
#: model:ir.model,name:website_sale_slides_order_line_link.model_sale_order
msgid "Sales Order"
msgstr ""

#. module: website_sale_slides_order_line_link
#: model:ir.model,name:website_sale_slides_order_line_link.model_sale_order_line
msgid "Sales Order Line"
msgstr ""

#. module: website_sale_slides_order_line_link
#: model:ir.model.fields,field_description:website_sale_slides_order_line_link.field_sale_order_line__slide_channel_partner_id
msgid "Slide Channel Partner"
msgstr ""
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,40 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-01-30 10:53+0000\n"
"PO-Revision-Date: 2026-01-30 10:53+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: website_sale_slides_order_line_link
#. odoo-python
#: code:addons/website_sale_slides_order_line_link/models/sale_order.py:0
#, python-format
msgid ""
"<p>Your registrations for the course <strong>%(course_name)s</strong> have "
"been increased by <strong>%(added_qty)s registration(s)</strong>.</p><p>You "
"now have a total of <strong>%(available_registrations)s</strong> "
"registration(s) purchased, of which <strong>%(used_registrations)s</strong> "
"have already been used and <strong>%(remaining_registrations)s</strong> are "
"still available.</p>"
msgstr ""

#. module: website_sale_slides_order_line_link
#: model:ir.model,name:website_sale_slides_order_line_link.model_slide_channel_partner
msgid "Channel / Partners (Members)"
msgstr ""

#. module: website_sale_slides_order_line_link
#. odoo-python
#: code:addons/website_sale_slides_order_line_link/models/sale_order.py:0
#, python-format
msgid "Course Registrations Added: %s"
msgstr ""

#. module: website_sale_slides_order_line_link
#: model:ir.model.fields,field_description:website_sale_slides_order_line_link.field_slide_channel_partner__sale_order_line_ids
msgid "Sale Order Lines"
Expand Down
54 changes: 52 additions & 2 deletions website_sale_slides_order_line_link/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Copyright 2025 Tecnativa - Pilar Vargas
# Copyright 2025-2026 Tecnativa - Pilar Vargas
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from markupsafe import Markup

from odoo import fields, models
from odoo import _, fields, models


class SaleOrder(models.Model):
Expand All @@ -12,11 +13,60 @@ def _action_confirm(self):
lambda line: line.product_id.channel_ids
)
if course_lines:
for line in course_lines:
existing_parent = self.env["slide.channel.partner"].search(
[
("channel_id", "in", line.product_id.channel_ids.ids),
("partner_id", "=", self.partner_id.id),
("sale_order_line_ids", "!=", False),
],
limit=1,
)
if existing_parent:
linked_lines_this_order = (
existing_parent.sale_order_line_ids.filtered(
lambda ln: ln.order_id.id == self.id
)
)
commands = [(3, ln.id) for ln in linked_lines_this_order]
commands.append((4, line.id))
existing_parent.write({"sale_order_line_ids": commands})
if not linked_lines_this_order:
self._send_registrations_added_mail(
line.product_uom_qty, existing_parent
)
return super(
SaleOrder, self.with_context(course_sale_order_lines=course_lines)
)._action_confirm()
return super()._action_confirm()

def _send_registrations_added_mail(self, added_qty, registration):
body = Markup(
_(
"<p>Your registrations for the course <strong>%(course_name)s</strong> "
"have been increased by <strong>%(added_qty)s registration(s)</strong>."
"</p>"
"<p>You now have a total of "
"<strong>%(available_registrations)s</strong> "
"registration(s) purchased, of which "
"<strong>%(used_registrations)s</strong> have already been used and "
"<strong>%(remaining_registrations)s</strong> are still available.</p>",
course_name=registration.channel_id.name,
added_qty=int(added_qty),
available_registrations=registration.available_registrations,
used_registrations=registration.used_registrations,
remaining_registrations=registration.remaining_registrations,
)
)
self.message_post(
body=body,
subject=_("Course Registrations Added: %s") % registration.channel_id.name,
message_type="comment",
subtype_xmlid="mail.mt_comment",
partner_ids=[self.partner_id.id],
email_layout_xmlid="mail.mail_notification_light",
)


class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
Expand Down