From 145bd8c49fcc6b9f2dc0c5113dca6112d1f541a8 Mon Sep 17 00:00:00 2001 From: oco-odoo Date: Mon, 9 Dec 2019 12:57:41 +0000 Subject: [PATCH] [FIX] account: when changing the country of a tax report, only delete the tags if they are not linked to any other report Before that, we deleted all the tags and removed them from the repartition lines all the time; we only want to do that if the tags are not shared with another report, so we use == instead of 'in'. closes odoo/odoo#41579 X-original-commit: 5f147681c721f5de609622f2cf80b3919eaf49bf Signed-off-by: oco-odoo --- addons/account/models/account.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account.py b/addons/account/models/account.py index ccb0646e009..524efd3adc6 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -95,7 +95,8 @@ class AccountTaxReport(models.Model): new_tags = tags_cache[cache_key] if new_tags: - tags_to_unlink = line.tag_ids.filtered(lambda x: record in x.mapped('tax_report_line_ids.report_id')) + tags_to_unlink = line.tag_ids.filtered(lambda x: record == x.mapped('tax_report_line_ids.report_id')) + # == instead of in, as we only want tags_to_unlink to contain the tags that are not linked to any other report than the one we're considering line.write({'tag_ids': [(6, 0, new_tags.ids)]}) self.env['account.tax.report.line']._delete_tags_from_taxes(tags_to_unlink.ids)