[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.
This commit is contained in:
Pedro M. Baeza
2025-02-01 11:23:25 +01:00
parent 41992c7f7c
commit 47e88819e6
3 changed files with 21 additions and 5 deletions

View File

@@ -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)