[FIX] account: format transfer source containing %

Steps to reproduce:
- Install Accounting app
- Go to the Accounting app
- Go to Configuration > Chart of Accounts and create a New account with a name containing %
- Go to Accounting > Journal Items
- Select a Jounral item and from Actions, choose move to Account
- In the popup displayed, choose the new account created ealier in the To field, and choose a Journal
- Click `Create Journal Entries`, an error arises

Invistigation:
When the `account_target_name` contains a % literal (ex. "test %"), the `transfer_format` beccomes `"{amount} ({debit_credit}) from %s were transferred to <strong>test %</strong> by {link}"` https://github.com/odoo/odoo/blob/a56586119845969e9d867a220f5330a6c7daa5c2/addons/account/wizard/account_automatic_entry_wizard.py#L429-

- You can notice that now the string has two % placeholders that need two be substituted, but only argument is provided which is `account.display_name` and so we get a the error `TypeError: not enough arguments for format string` https://github.com/odoo/odoo/blob/a56586119845969e9d867a220f5330a6c7daa5c2/addons/account/wizard/account_automatic_entry_wizard.py#L433

opw-3601886

closes odoo/odoo#145762

X-original-commit: 1582a0ae28fec12175845dcfdebbb8d6b4bcde33
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Ali Hassan Youssef (alhy) <alhy@odoo.com>
This commit is contained in:
AH-Yussef
2023-12-12 10:34:46 +00:00
parent 230b680bf9
commit 31c7a2ff90
@@ -477,7 +477,7 @@ class AutomaticEntryWizard(models.TransientModel):
return Markup("<ul>%s</ul>") % Markup().join([
Markup("<li>%s</li>") % \
self._format_strings(transfer_format, transfer_move, balance) % (Markup("<strong>%s</strong>") % account.display_name)
self._format_strings(transfer_format % (Markup("<strong>%s</strong>") % account.display_name), transfer_move, balance)
for account, balance in balances_per_account.items()
if account != self.destination_account_id
])