[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 <oco-odoo@users.noreply.github.com>
This commit is contained in:
oco-odoo
2019-12-09 12:57:41 +00:00
parent b2465a48bb
commit 145bd8c49f
+2 -1
View File
@@ -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)