diff --git a/l10n_es_vat_prorate/models/account_move.py b/l10n_es_vat_prorate/models/account_move.py index 636f9479cde..3dc09d40ac1 100644 --- a/l10n_es_vat_prorate/models/account_move.py +++ b/l10n_es_vat_prorate/models/account_move.py @@ -63,6 +63,17 @@ def _process_aeat_tax_fee_info(self, res, tax, sign): res[tax]["deductible_amount"] -= self.balance * sign return result + def _prepare_vat_prorate_key(self): + self.ensure_one() + return { + "vat_prorate": True, + "account_id": self.company_id._get_tax_prorrate_account_map().get( + self.account_id.account_type + ) + or self.account_id.id, + "analytic_distribution": self.analytic_distribution, + } + @api.depends("with_vat_prorate") def _compute_all_tax(self): """After getting normal taxes dict that is dumped into this field, we loop @@ -100,16 +111,7 @@ def _compute_all_tax(self): new_vals[field] -= tax_vals[field] new_vals["vat_prorate"] = True new_key = dict(tax_key) - new_key.update( - { - "vat_prorate": True, - "account_id": line.company_id._get_tax_prorrate_account_map().get( - line.account_id.account_type - ) - or line.account_id.id, - "analytic_distribution": line.analytic_distribution, - } - ) + new_key.update(line._prepare_vat_prorate_key()) new_key = frozendict(new_key) if prorate_tax_list.get(new_key): for field in {"amount_currency", "balance"}: