[FIX] account: prevent traceback while reload template

When a new tax is created and click on Reload button of fiscal Localization it
will generate traceback.

Steps to Produce:-
- Create a new Tax.
- Then open the setting of invoicing and Click on reload Button which is located
  inside fiscal Localization.
- IndexError will be generated.

Cause:-
- When a user creates a tax from UI `get_external_id` return an empty string and
we try to `spilt` an empty string and get 1 index value and because of that
it gives traceback.

Fix:-
- Check xml_id is not null before trying to spilt and get the value from xml_id.

Sentry-4042986115

closes odoo/odoo#117709

X-original-commit: 3b86115d5f989c3b35579e75c67d94d120ef6be2
Signed-off-by: William André (wan) <wan@odoo.com>
This commit is contained in:
Adesh Jolhe
2023-04-04 19:11:55 +02:00
parent ef8dc0a167
commit c039064ca4
+1 -1
View File
@@ -235,7 +235,7 @@ class AccountChartTemplate(models.AbstractModel):
unique_tax_name_keys = set(current_taxes.mapped(unique_tax_name_key))
xmlid2tax = {
xml_id.split('.')[1].split('_', maxsplit=1)[1]: self.env['account.tax'].browse(record)
for record, xml_id in current_taxes.get_external_id().items()
for record, xml_id in current_taxes.get_external_id().items() if xml_id
}
def tax_template_changed(tax, template):
return (