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 # -------------------------------------------------------------------------