From 393aff1f07611d7fb064677ca24df99cc7fd277b Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Mon, 9 Jan 2023 14:34:21 +0100 Subject: [PATCH] Update parent and replaced_by when template has no taxes Closes #11891 (grafted from 46a73ccc6b68e222baa5e60218eee5ef3b6f0637) --HG-- branch : 6.0 --- modules/account/account.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/modules/account/account.py b/modules/account/account.py index 79ade44b55..9cfe5edc6d 100644 --- a/modules/account/account.py +++ b/modules/account/account.py @@ -1246,19 +1246,17 @@ class Account(AccountMixin(), ActivePeriodMixin, tree(), ModelSQL, ModelView): for child in childs: if not child.template: continue - if not child.template.taxes: - continue values = {} tax_ids = [template2tax[x.id] for x in child.template.taxes if x.id in template2tax] old_tax_ids = [x.id for x in child.taxes] - for tax_id in tax_ids: - if tax_id not in old_tax_ids: - values['taxes'] = [ - ('add', [template2tax[x.id] - for x in child.template.taxes - if x.id in template2tax])] - break + taxes_to_add = [x for x in tax_ids if x not in old_tax_ids] + taxes_to_remove = [x for x in old_tax_ids if x not in tax_ids] + if taxes_to_add or taxes_to_remove: + values['taxes'] = [ + ('add', taxes_to_add), + ('remove', taxes_to_remove), + ] if child.template.parent: parent = template2account[child.template.parent.id] else: