2
0

[FIX] format string translate

This commit is contained in:
Saran440 2023-09-13 16:42:44 +07:00 committed by Andrea Stirpe
parent f3cd6619e1
commit e2ab9e5fdb
3 changed files with 25 additions and 16 deletions

View File

@ -103,12 +103,20 @@ class AccountMoveLine(models.Model):
if reconciled_lines:
msg = _("Cannot reconcile entries that are already reconciled:\n")
for line in reconciled_lines:
msg += msg_line % (line.id, line.name, line.account_id.code)
msg += msg_line % {
"line_id": line.id,
"line_name": line.name,
"account_code": line.account_id.code,
}
raise ValidationError(msg)
if len(self.mapped("account_id").ids) > 1:
msg = _("Some entries are not from the same account:\n")
for line in self:
msg += msg_line % (line.id, line.name, line.account_id.code)
msg += msg_line % {
"line_id": line.id,
"line_name": line.name,
"account_code": line.account_id.code,
}
raise ValidationError(msg)
def create_auto_spread(self):
@ -148,9 +156,10 @@ class AccountMoveLine(models.Model):
elif len(template) > 1:
raise UserError(
_(
"Too many auto spread templates ({}) matched with the "
"invoice line, {}"
).format(len(template), line.display_name)
"Too many auto spread templates (%(len_template)s) matched with the "
"invoice line, %(line_name)s"
)
% {"len_template": len(template), "line_name": line.display_name}
)
# Found auto spread template for this invoice line, create it
wizard = self.env["account.spread.invoice.line.link.wizard"].new(

View File

@ -520,19 +520,21 @@ class AccountSpread(models.Model):
"<a href=# data-oe-model=account.move "
"data-oe-id=%d>%s</a>" % (spread.invoice_id.id, _("Invoice"))
)
msg_body = _("Unlinked invoice line '{}' (view {}).").format(
spread.invoice_line_id.name,
inv_link,
)
msg_body = _(
"Unlinked invoice line '%(spread_line_name)s' (view %(inv_link)s)."
) % {
"spread_line_name": spread.invoice_line_id.name,
"inv_link": inv_link,
}
spread.message_post(body=msg_body)
spread_link = (
"<a href=# data-oe-model=account.spread "
"data-oe-id=%d>%s</a>" % (spread.id, _("Spread"))
)
msg_body = _("Unlinked '{}' (invoice line {}).").format(
spread_link,
spread.invoice_line_id.name,
)
msg_body = _("Unlinked '%(spread_link)s' (invoice line %(inv_line)s).") % {
"spread_link": spread_link,
"inv_line": spread.invoice_line_id.name,
}
spread.invoice_id.message_post(body=msg_body)
def unlink(self):

View File

@ -169,9 +169,7 @@ class AccountSpreadTemplate(models.Model):
)
if results:
raise UserError(
_("Followings are duplicated combinations,\n\n{}").format(
"\n".join(results)
)
_("Followings are duplicated combinations,\n\n%s") % "\n".join(results)
)