From 477365a608cdd6854035197c73dee53269d4dcc7 Mon Sep 17 00:00:00 2001 From: "John Laterre (jol)" Date: Thu, 9 Dec 2021 13:51:36 +0000 Subject: [PATCH] [FIX] l10n_nl_edi: fix traceback when posting an invoice With the previous fix, if the company created an invoice for a non-EAS client in a journal used for EAS clients, it would raise a UserError. That behavior was not intended, and is being fixed here. Related PR odoo/odoo#80740 closes odoo/odoo#81360 X-original-commit: 81209239d1ef38ad6c53dd7706d57fb9312bda82 Signed-off-by: Laurent Smet Signed-off-by: John Laterre --- addons/l10n_nl_edi/models/account_edi_format.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/l10n_nl_edi/models/account_edi_format.py b/addons/l10n_nl_edi/models/account_edi_format.py index 3fc35303b54..503b9afb78d 100644 --- a/addons/l10n_nl_edi/models/account_edi_format.py +++ b/addons/l10n_nl_edi/models/account_edi_format.py @@ -100,8 +100,6 @@ class AccountEdiFormat(models.Model): errors.append(_("Customer's address must include street, zip and city (%s).", customer.display_name)) if customer.country_code == 'NL' and not customer.l10n_nl_kvk and not customer.l10n_nl_oin: errors.append(_("The customer %s must have a KvK-nummer or OIN.", customer.display_name)) - if customer.country_code not in COUNTRY_EAS: - errors.append(_("Customer's country must belong to the EAS (Electronic Address Scheme) code list.")) if not invoice.partner_bank_id: errors.append(_("The supplier %s must have a bank account.", supplier.display_name)) @@ -141,3 +139,10 @@ class AccountEdiFormat(models.Model): if self.code == 'nlcius_1' and self._is_nlcius(filename, tree): return self._decode_bis3(tree, invoice) return super()._update_invoice_from_xml_tree(filename, tree, invoice) + + def _is_required_for_invoice(self, invoice): + self.ensure_one() + if self.code != 'nlcius_1': + return super()._is_required_for_invoice(invoice) + + return invoice.commercial_partner_id.country_code in COUNTRY_EAS