From 7d5dc4d26a2e3195158fce7d5e45f942900b4bcb Mon Sep 17 00:00:00 2001 From: Parthiv Patel Date: Thu, 25 Jan 2024 08:34:23 +0000 Subject: [PATCH] [PATCH] Upstream patch - 25012024 --- .../11.1/end-migrate_update_taxes.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/addons/l10n_ch/migrations/11.1/end-migrate_update_taxes.py b/addons/l10n_ch/migrations/11.1/end-migrate_update_taxes.py index 105fdcabe9..479977c94b 100644 --- a/addons/l10n_ch/migrations/11.1/end-migrate_update_taxes.py +++ b/addons/l10n_ch/migrations/11.1/end-migrate_update_taxes.py @@ -7,13 +7,17 @@ def migrate(cr, version): env = api.Environment(cr, SUPERUSER_ID, {}) # We had corrupted data, handle the correction so the tax update can proceed. # See https://github.com/flectra/flectra/commit/7b07df873535446f97abc1de9176b9332de5cb07 - taxes_to_check = ('vat_purchase_81_return', 'vat_77_purchase_return') - tax_ids = env['ir.model.data'].search([('name', 'in', taxes_to_check)]).mapped('res_id') - for tax in env['account.tax'].browse(tax_ids): - for child in tax.children_tax_ids: - if child.type_tax_use not in ('none', tax.type_tax_use): - # set the child to it's parent's value - child.type_tax_use = tax.type_tax_use + for company in env.companies: + taxes_to_check = (f'{company.id}_vat_purchase_81_reverse', f'{company.id}_vat_77_purchase_reverse') + tax_ids = env['ir.model.data'].search([ + ('name', 'in', taxes_to_check), + ('model', '=', 'account.tax'), + ]).mapped('res_id') + for tax in env['account.tax'].browse(tax_ids).with_context(active_test=False): + for child in tax.children_tax_ids: + if child.type_tax_use not in ('none', tax.type_tax_use): + # set the child to it's parent's value + child.type_tax_use = tax.type_tax_use # Update taxes new_template_to_tax = update_taxes_from_templates(cr, 'l10n_ch.l10nch_chart_template')