From 2e35ae4194488037d91fc4865dae89d21042d5b7 Mon Sep 17 00:00:00 2001 From: aktr-odoo Date: Fri, 21 Jul 2023 13:08:09 +0000 Subject: [PATCH] [FIX] l10n_es_edi_facturae: handle traceback while send an invoice to partner When the user attempts to send an invoice to a partner whose country code is not set. Steps to produce: - Install sale_management,l10n_es_edi_facturae - Open invoicing module > Create a new invoice - Select a customer who does not have set country_id. - Click on Add a line > Select any product - Click on Confirm > Click on Send & Print > Click on save - Click on Send & Print - Error will be produced This commit addresses a `KeyError False` while the user attempts to send an invoice to a partner without a set country code. The function `_l10n_es_edi_facturae_export_facturae` uses the partner's country code but the partner doesn't have a set country code. As a result, a `KeyError` traceback is generated. Sentry-4330095746 closes odoo/odoo#130382 X-original-commit: 421d370ed30ff92a85bf7db0f4d6f1f3431b2b34 Signed-off-by: John Laterre (jol) --- addons/l10n_es_edi_facturae/i18n/l10n_es_edi_facturae.pot | 7 +++++++ addons/l10n_es_edi_facturae/models/account_move.py | 2 ++ 2 files changed, 9 insertions(+) diff --git a/addons/l10n_es_edi_facturae/i18n/l10n_es_edi_facturae.pot b/addons/l10n_es_edi_facturae/i18n/l10n_es_edi_facturae.pot index 18c8db4384b..7d88874d8ba 100644 --- a/addons/l10n_es_edi_facturae/i18n/l10n_es_edi_facturae.pot +++ b/addons/l10n_es_edi_facturae/i18n/l10n_es_edi_facturae.pot @@ -551,6 +551,13 @@ msgstr "" msgid "The date on which the certificate starts to be valid" msgstr "" +#. module: l10n_es_edi_facturae +#. odoo-python +#: code:addons/l10n_es_edi_facturae/models/account_move.py:0 +#, python-format +msgid "The partner needs a set country" +msgstr "" + #. module: l10n_es_edi_facturae #. odoo-python #: code:addons/l10n_es_edi_facturae/models/account_move.py:0 diff --git a/addons/l10n_es_edi_facturae/models/account_move.py b/addons/l10n_es_edi_facturae/models/account_move.py index 9e7f1af87c3..82cc8cea038 100644 --- a/addons/l10n_es_edi_facturae/models/account_move.py +++ b/addons/l10n_es_edi_facturae/models/account_move.py @@ -253,6 +253,8 @@ class AccountMove(models.Model): raise UserError(_('The company needs a set tax identification number or VAT number')) if not partner.vat: raise UserError(_('The partner needs a set tax identification number or VAT number')) + if not partner.country_id: + raise UserError(_("The partner needs a set country")) if self.move_type == "entry": return False