From c911e63c6f0fc48891bb86beddd3e59e84446d89 Mon Sep 17 00:00:00 2001 From: "Maruan Aguerdouh (magm)" Date: Fri, 2 Dec 2022 11:40:08 +0000 Subject: [PATCH] [FIX] account_edi_ubl_cii: send and print working properly for invoices with canary islands taxes Steps to reproduce: 1. Go to Apps, and Install the module `l10n_es` 2. Go to Accounting App > Customer invoices 3. Create a new Invoice with fake comany, fake address with state set as `Santa Cruz de Tenerife (ES)` and the ZIP set as 38400. 4. Add any line to the invoice and confirm. 5. Try to Send & Print the invoice, you may need to select the template before. Issue: We won't be able to either print or send the Invoice getting a traceback containing `KeyError: 'tax_details_per_record'`. Solution: Keys for `vals` have change so we need to adapt it to match new keys naming and sorting for accesing the same values. FW - port: master opw-3067491 closes odoo/odoo#107176 X-original-commit: accb722d12e76d178ba70b884a020e162e73634f Signed-off-by: Grazioso Andrea (agr) --- .../account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py | 4 ++-- 1 file changed, 2 insertions(+), 2 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 32fb0ba4def..3c04849f7d0 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 @@ -88,8 +88,8 @@ class AccountEdiXmlCII(models.AbstractModel): "shall be categorized with an Invoiced item VAT category code (BT-151).") def _check_non_0_rate_tax(self, vals): - for line_vals in vals['tax_details_per_record']: - tax_rate_list = line_vals['line'].tax_ids.flatten_taxes_hierarchy().mapped("amount") + for line_vals in vals['tax_details']['tax_details_per_record']: + tax_rate_list = line_vals.tax_ids.flatten_taxes_hierarchy().mapped("amount") if not any([rate > 0 for rate in tax_rate_list]): return _("When the Canary Island General Indirect Tax (IGIC) applies, the tax rate on " "each invoice line should be greater than 0.")