[FIX] account: we need to find back xml_id in existing accounts instead of browsing directly

Before, when instantiating the taxes for France in a Belgian
company through a French fiscal position (multi-vat),
a traceback would be shown because the cash based transition
account would not be retrieved in the correct way.

By checking the existing accounts (which
are created on the fly for multi-vat) instead of browsing the record
and also, by allowing no account at all, we avoid tracebacks and the
taxes get created.

closes odoo/odoo#126473

X-original-commit: 85f45e37c4ad9503dcc96c321d26504bce3de2c0
Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
This commit is contained in:
Josse Colpaert
2023-06-26 23:23:06 +02:00
parent 7544af9436
commit 53d41e7028
+2 -1
View File
@@ -730,9 +730,10 @@ class AccountChartTemplate(models.AbstractModel):
account_id = [rep_line['account_id'] for _command, _id, rep_line in tax_template['repartition_line_ids'] if rep_line.get('account_id')]
if account_id:
local_account = self.env['account.account'].browse(account_id[0])
local_account = self.env['account.account'].browse(existing_accounts[account_id[0]])
existing_accounts[account_xml_id] = create_foreign_tax_account(local_account, _("Cash basis transition account")).id
continue
existing_accounts[account_xml_id] = None
# Assign the account based on the map
for field, account_name in field_and_names: