[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) <ayh@odoo.com>
Signed-off-by: Laurent Smet (las) <las@odoo.com>
This commit is contained in:
Laurent Smet
2023-08-08 08:56:15 +02:00
parent 248ee476fd
commit c8b5fdbb44
3 changed files with 12 additions and 8 deletions
@@ -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
@@ -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
@@ -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)