From 9492a11d2af4964ffb4b308f287b02b38fcd152c Mon Sep 17 00:00:00 2001 From: Mehdi Bendali Hacine Date: Thu, 8 Jun 2023 12:04:11 +0000 Subject: [PATCH] [IMP] account_edi_ubl_cii: Add function to apply filter on tax values For SA, we need to be able to filter on the taxes exported, as certain taxes should simply not be reported in the UBL. X-original-commit: 6019e809b4eedfd5ba56e5f8b39ac4e830131390 Part-of: odoo/odoo#126353 --- .../models/account_edi_xml_ubl_20.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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 23104de23ca..9df49d5a678 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 @@ -337,6 +337,19 @@ class AccountEdiXmlUBL20(models.AbstractModel): 'price_vals': self._get_invoice_line_price_vals(line), } + def _apply_invoice_tax_filter(self, base_line, tax_values): + """ + To be overridden to apply a specific tax filter + """ + return True + + + def _apply_invoice_line_filter(self, invoice_line): + """ + To be overridden to apply a specific invoice line filter + """ + return True + def _export_invoice_vals(self, invoice): def grouping_key_generator(base_line, tax_values): tax = tax_values['tax_repartition_line'].tax_id @@ -357,7 +370,9 @@ 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) + 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) # 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 @@ -462,7 +477,6 @@ class AccountEdiXmlUBL20(models.AbstractModel): vals['vals']['credit_note_type_code'] = 381 return vals - def _export_invoice_constraints(self, invoice, vals): constraints = self._invoice_constraints_common(invoice) constraints.update({