From 19ed26bbfc962ed66b8835f9843857535e1d635c Mon Sep 17 00:00:00 2001 From: aliya Date: Mon, 30 Oct 2023 16:05:24 +0100 Subject: [PATCH] [FIX] account_peppol: restrict peppol journal Currently, although the journals are filtered to only show purchase journals, there is no constraint preventing users creating a new journal of any other type. This commit adds a constraint. closes odoo/odoo#140458 X-original-commit: 014435f09cabbf0b21f3f9809eb1e0f13d35661a Signed-off-by: Laurent Smet (las) Signed-off-by: Aliya Tastemirova (alta) --- addons/account_peppol/i18n/account_peppol.pot | 7 +++++++ addons/account_peppol/models/res_company.py | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/addons/account_peppol/i18n/account_peppol.pot b/addons/account_peppol/i18n/account_peppol.pot index facdb542255..8769f5e07a1 100644 --- a/addons/account_peppol/i18n/account_peppol.pot +++ b/addons/account_peppol/i18n/account_peppol.pot @@ -48,6 +48,13 @@ msgid "" " " msgstr "" +#. module: account_peppol +#. odoo-python +#: code:addons/account_peppol/models/res_company.py:0 +#, python-format +msgid "A purchase journal must be used to receive Peppol documents." +msgstr "" + #. module: account_peppol #: model:ir.model,name:account_peppol.model_account_edi_proxy_client_user msgid "Account EDI proxy user" diff --git a/addons/account_peppol/models/res_company.py b/addons/account_peppol/models/res_company.py index abf8b05b620..f2f52ea26d3 100644 --- a/addons/account_peppol/models/res_company.py +++ b/addons/account_peppol/models/res_company.py @@ -135,6 +135,12 @@ class ResCompany(models.Model): if not company._check_peppol_endpoint_number(PEPPOL_ENDPOINT_RULES): raise ValidationError(_("The Peppol endpoint identification number is not correct.")) + @api.constrains('peppol_purchase_journal_id') + def _check_peppol_purchase_journal_id(self): + for company in self: + if company.peppol_purchase_journal_id and company.peppol_purchase_journal_id.type != 'purchase': + raise ValidationError(_("A purchase journal must be used to receive Peppol documents.")) + # ------------------------------------------------------------------------- # COMPUTE METHODS # -------------------------------------------------------------------------