From b61a45ea72c592d9b13250c396c0dac564176e12 Mon Sep 17 00:00:00 2001 From: Josse Colpaert <jco@odoo.com> Date: Wed, 19 Apr 2023 13:57:23 +0000 Subject: [PATCH] [FIX] l10n_es_edi_sii: separate S1 and S2 for noexenta + multiple noexenta Before, if you had multiple lines with noexenta, the lines could be added multiple times. So, we only add the lines outside of the for-loop. For Ticketbai, we also need to make the distinction between S1 (normal) and S2 (inversion sujeto pasivo) lines, so we return them in different lists. Part-of: odoo/odoo#109907 --- .../models/account_edi_format.py | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/addons/l10n_es_edi_sii/models/account_edi_format.py b/addons/l10n_es_edi_sii/models/account_edi_format.py index 77d5ca9b9fe4..f3e776b2267e 100644 --- a/addons/l10n_es_edi_sii/models/account_edi_format.py +++ b/addons/l10n_es_edi_sii/models/account_edi_format.py @@ -158,22 +158,6 @@ class AccountEdiFormat(models.Model): elif tax_values['l10n_es_type'] == 'ignore': continue - if tax_subject_isp_info_list and not tax_subject_info_list: - tax_details_info['Sujeta']['NoExenta'] = {'TipoNoExenta': 'S2'} - elif not tax_subject_isp_info_list and tax_subject_info_list: - tax_details_info['Sujeta']['NoExenta'] = {'TipoNoExenta': 'S1'} - elif tax_subject_isp_info_list and tax_subject_info_list: - tax_details_info['Sujeta']['NoExenta'] = {'TipoNoExenta': 'S3'} - - if tax_subject_info_list: - tax_details_info['Sujeta']['NoExenta'].setdefault('DesgloseIVA', {}) - tax_details_info['Sujeta']['NoExenta']['DesgloseIVA'].setdefault('DetalleIVA', []) - tax_details_info['Sujeta']['NoExenta']['DesgloseIVA']['DetalleIVA'] += tax_subject_info_list - if tax_subject_isp_info_list: - tax_details_info['Sujeta']['NoExenta'].setdefault('DesgloseIVA', {}) - tax_details_info['Sujeta']['NoExenta']['DesgloseIVA'].setdefault('DetalleIVA', []) - tax_details_info['Sujeta']['NoExenta']['DesgloseIVA']['DetalleIVA'] += tax_subject_isp_info_list - else: # Vendor bills if tax_values['l10n_es_type'] in ('sujeto', 'sujeto_isp', 'no_sujeto', 'no_sujeto_loc'): @@ -206,6 +190,22 @@ class AccountEdiFormat(models.Model): tax_info['TipoRecargoEquivalencia'] = recargo['applied_tax_amount'] tax_details_info['DetalleIVA'].append(tax_info) + if tax_subject_isp_info_list and not tax_subject_info_list: # Only for sale_invoices + tax_details_info['Sujeta']['NoExenta'] = {'TipoNoExenta': 'S2'} + elif not tax_subject_isp_info_list and tax_subject_info_list: + tax_details_info['Sujeta']['NoExenta'] = {'TipoNoExenta': 'S1'} + elif tax_subject_isp_info_list and tax_subject_info_list: + tax_details_info['Sujeta']['NoExenta'] = {'TipoNoExenta': 'S3'} + + if tax_subject_info_list: + tax_details_info['Sujeta']['NoExenta'].setdefault('DesgloseIVA', {}) + tax_details_info['Sujeta']['NoExenta']['DesgloseIVA'].setdefault('DetalleIVA', []) + tax_details_info['Sujeta']['NoExenta']['DesgloseIVA']['DetalleIVA'] += tax_subject_info_list + if tax_subject_isp_info_list: + tax_details_info['Sujeta']['NoExenta'].setdefault('DesgloseIVA', {}) + tax_details_info['Sujeta']['NoExenta']['DesgloseIVA'].setdefault('DetalleIVA', []) + tax_details_info['Sujeta']['NoExenta']['DesgloseIVA']['DetalleIVA'] += tax_subject_isp_info_list + if not invoice.company_id.currency_id.is_zero(base_amount_not_subject) and invoice.is_sale_document(): tax_details_info['NoSujeta']['ImportePorArticulos7_14_Otros'] = round(sign * base_amount_not_subject, 2) if not invoice.company_id.currency_id.is_zero(base_amount_not_subject_loc) and invoice.is_sale_document(): @@ -217,6 +217,8 @@ class AccountEdiFormat(models.Model): 'tax_amount_deductible': tax_amount_deductible, 'tax_amount_retention': tax_amount_retention, 'base_amount_not_subject': base_amount_not_subject, + 'S1_list': tax_subject_info_list, #TBAI has separate sections for S1 and S2 + 'S2_list': tax_subject_isp_info_list, #TBAI has separate sections for S1 and S2 } def _l10n_es_edi_get_partner_info(self, partner): -- GitLab