From 895cc4b4de2294e9234e41dc4d86f8611385f56c 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 | 13 ++++--------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/contract/i18n/contract.pot b/contract/i18n/contract.pot index 2849eead78..83324a2203 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 323510e097..2fb2c543a3 100644 --- a/contract/i18n/es.po +++ b/contract/i18n/es.po @@ -2543,6 +2543,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 5b2b0ab596..036270315a 100644 --- a/contract/models/contract.py +++ b/contract/models/contract.py @@ -619,17 +619,12 @@ def _invoice_followers(self, invoices): def _add_contract_origin(self, invoices): for item in self: for move in invoices & item._get_related_invoices(): + translation = _("by contract") move.message_post( body=( - _( - ( - "%(msg)s by contract %(contract)s." - ), - msg=move._creation_message(), - contract_id=item.id, - contract=item.display_name, - ) + f"{move._creation_message()} {translation} " + f"{item.display_name}." ) )