diff --git a/website_sale_slides_order_line_link/i18n/es.po b/website_sale_slides_order_line_link/i18n/es.po new file mode 100644 index 0000000..6196781 --- /dev/null +++ b/website_sale_slides_order_line_link/i18n/es.po @@ -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 "" +"

Your registrations for the course %(course_name)s have " +"been increased by %(added_qty)s registration(s).

You " +"now have a total of %(available_registrations)s " +"registration(s) purchased, of which %(used_registrations)s " +"have already been used and %(remaining_registrations)s are " +"still available.

" +msgstr "" +"

Sus inscripciones para el curso %(course_name)s se han " +"incrementado en %(added_qty)s inscripción(es).

Ahora " +"dispone de un total de %(available_registrations)s " +"inscripción(es) adquiridas, de las cuales %(used_registrations)s ya se han utilizado y %(remaining_registrations)s " +"siguen disponibles.

" + +#. 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 "" diff --git a/website_sale_slides_order_line_link/i18n/website_sale_slides_order_line_link.pot b/website_sale_slides_order_line_link/i18n/website_sale_slides_order_line_link.pot index 3790ec2..f1097bf 100644 --- a/website_sale_slides_order_line_link/i18n/website_sale_slides_order_line_link.pot +++ b/website_sale_slides_order_line_link/i18n/website_sale_slides_order_line_link.pot @@ -6,6 +6,8 @@ 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" @@ -13,11 +15,31 @@ msgstr "" "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 "" +"

Your registrations for the course %(course_name)s have " +"been increased by %(added_qty)s registration(s).

You " +"now have a total of %(available_registrations)s " +"registration(s) purchased, of which %(used_registrations)s " +"have already been used and %(remaining_registrations)s are " +"still available.

" +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" diff --git a/website_sale_slides_order_line_link/models/sale_order.py b/website_sale_slides_order_line_link/models/sale_order.py index aded62e..816cf40 100644 --- a/website_sale_slides_order_line_link/models/sale_order.py +++ b/website_sale_slides_order_line_link/models/sale_order.py @@ -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): @@ -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( + _( + "

Your registrations for the course %(course_name)s " + "have been increased by %(added_qty)s registration(s)." + "

" + "

You now have a total of " + "%(available_registrations)s " + "registration(s) purchased, of which " + "%(used_registrations)s have already been used and " + "%(remaining_registrations)s are still available.

", + 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"