From 47e88819e6c454b64a5eea40a5212cc62efe7865 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Sat, 1 Feb 2025 11:23:25 +0100 Subject: [PATCH] [FIX] contract: Invoice creation message translatable As it was, the text to translate is not correctly extracted, so it's not translated, creating a mix of languages, as `_creation_message` is returning a translated sentence. We take also the opportunity to change the way the sentence is built for having as translatable only the "by contract" words, to avoid possible errors in translations due to the placeholders. --- contract/i18n/contract.pot | 7 +++++++ contract/i18n/es.po | 7 +++++++ contract/models/contract.py | 12 +++++++----- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/contract/i18n/contract.pot b/contract/i18n/contract.pot index e0d30dfe7..e0b87d5e5 100644 --- a/contract/i18n/contract.pot +++ b/contract/i18n/contract.pot @@ -2334,6 +2334,13 @@ msgstr "" msgid "You must supply a date of next invoice for contract line '%s'" msgstr "" +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract.py:0 +#, python-format +msgid "by contract" +msgstr "" + #. module: contract #: model_terms:ir.ui.view,arch_db:contract.contract_contract_form_view msgid "e.g. Contract XYZ" diff --git a/contract/i18n/es.po b/contract/i18n/es.po index 04684e3dd..787e7db42 100644 --- a/contract/i18n/es.po +++ b/contract/i18n/es.po @@ -2542,6 +2542,13 @@ msgstr "" "Debe proporcionar la fecha de la próxima factura para la línea del contrato " "'%s'" +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract.py:0 +#, python-format +msgid "by contract" +msgstr "por el contrato" + #. module: contract #: model_terms:ir.ui.view,arch_db:contract.contract_contract_form_view msgid "e.g. Contract XYZ" diff --git a/contract/models/contract.py b/contract/models/contract.py index 1ad85e4c6..1315b85ac 100644 --- a/contract/models/contract.py +++ b/contract/models/contract.py @@ -613,11 +613,13 @@ class ContractContract(models.Model): def _add_contract_origin(self, invoices): for item in self: for move in invoices & item._get_related_invoices(): - body = Markup(_("%(msg)s by contract: %(contract_link)s")) % { - "msg": move._creation_message(), - "contract_link": item._get_html_link(title=item.display_name), - } - move.message_post(body=body) + translation = _("by contract") + move.message_post( + body=Markup( + f"{move._creation_message()} {translation} " + f"{item._get_html_link(title=item.display_name)}." + ) + ) def _recurring_create_invoice(self, date_ref=False): invoices_values = self._prepare_recurring_invoices_values(date_ref)