From c8b5fdbb44645a6dcc675ba86c26238bec01553f Mon Sep 17 00:00:00 2001 From: Laurent Smet Date: Mon, 7 Aug 2023 13:33:45 +0000 Subject: [PATCH] [FIX] account_edi_ubl_cii: Fix call to '_prepare_edi_tax_details' This module no longer depends of account_edi. Then, `_prepare_edi_tax_details` can't not be used. We need to use `_prepare_invoice_aggregated_taxes` instead. closes odoo/odoo#131109 X-original-commit: 89debfc12e2712a03896080a707cee6942b11581 Signed-off-by: Habib Ayob (ayh) Signed-off-by: Laurent Smet (las) --- .../models/account_edi_xml_cii_facturx.py | 2 +- .../models/account_edi_xml_ubl_20.py | 8 +++++--- .../l10n_sa_edi/models/account_edi_xml_ubl_21_zatca.py | 10 ++++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py b/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py index ca9a3d988d6..2040ee0f89c 100644 --- a/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py +++ b/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py @@ -140,7 +140,7 @@ class AccountEdiXmlCII(models.AbstractModel): self._validate_taxes(invoice) # Create file content. - tax_details = invoice._prepare_edi_tax_details(grouping_key_generator=grouping_key_generator) + tax_details = invoice._prepare_invoice_aggregated_taxes(grouping_key_generator=grouping_key_generator) # Fixed Taxes: filter them on the document level, and adapt the totals # Fixed taxes are not supposed to be taxes in real live. However, this is the way in Odoo to manage recupel diff --git a/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py b/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py index 6a8a865f6cb..1b905f5278b 100644 --- a/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py +++ b/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py @@ -370,9 +370,11 @@ class AccountEdiXmlUBL20(models.AbstractModel): self._validate_taxes(invoice) # Compute the tax details for the whole invoice and each invoice line separately. - taxes_vals = invoice._prepare_edi_tax_details(grouping_key_generator=grouping_key_generator, - filter_to_apply=self._apply_invoice_tax_filter, - filter_invl_to_apply=self._apply_invoice_line_filter) + taxes_vals = invoice._prepare_invoice_aggregated_taxes( + grouping_key_generator=grouping_key_generator, + filter_tax_values_to_apply=self._apply_invoice_tax_filter, + filter_invl_to_apply=self._apply_invoice_line_filter, + ) # Fixed Taxes: filter them on the document level, and adapt the totals # Fixed taxes are not supposed to be taxes in real live. However, this is the way in Odoo to manage recupel diff --git a/addons/l10n_sa_edi/models/account_edi_xml_ubl_21_zatca.py b/addons/l10n_sa_edi/models/account_edi_xml_ubl_21_zatca.py index 02b607b79d8..f84925fe59b 100644 --- a/addons/l10n_sa_edi/models/account_edi_xml_ubl_21_zatca.py +++ b/addons/l10n_sa_edi/models/account_edi_xml_ubl_21_zatca.py @@ -194,7 +194,9 @@ class AccountEdiXmlUBL21Zatca(models.AbstractModel): """ Calculate the down-payment amount according to ZATCA rules """ downpayment_lines = False if invoice._is_downpayment() else invoice.line_ids.filtered(lambda l: l._get_downpayment_lines()) if downpayment_lines: - tax_vals = invoice._prepare_edi_tax_details(filter_to_apply=lambda l, t: not self.env['account.tax'].browse(t['id']).l10n_sa_is_retention) + tax_vals = invoice._prepare_invoice_aggregated_taxes( + filter_tax_values_to_apply=lambda l, t: not self.env['account.tax'].browse(t['id']).l10n_sa_is_retention + ) base_amount = abs(sum(tax_vals['tax_details_per_record'][l]['base_amount_currency'] for l in downpayment_lines)) tax_amount = abs(sum(tax_vals['tax_details_per_record'][l]['tax_amount_currency'] for l in downpayment_lines)) return { @@ -331,9 +333,9 @@ class AccountEdiXmlUBL21Zatca(models.AbstractModel): # values to set in the TaxableAmount and TaxAmount nodes on the InvoiceLine for the down payment. # This means ZATCA will return a warning message for the BR-KSA-80 rule since it cannot calculate the # TaxableAmount and the TaxAmount nodes correctly. To avoid this, we re-caclculate the taxes_vals just before - # we set the values for the down payment line, and we do not pass any filters to the _prepare_edi_tax_details - # method - line_taxes = line.move_id._prepare_edi_tax_details(grouping_key_generator=grouping_key_generator) + # we set the values for the down payment line, and we do not pass any filters to the + # _prepare_invoice_aggregated_taxes method + line_taxes = line.move_id._prepare_invoice_aggregated_taxes(grouping_key_generator=grouping_key_generator) taxes_vals = line_taxes['tax_details_per_record'][line] line_vals = super()._get_invoice_line_vals(line, taxes_vals)