[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) <las@odoo.com>
Signed-off-by: Aliya Tastemirova (alta) <alta@odoo.com>
This commit is contained in:
aliya
2023-10-31 14:41:00 +00:00
parent 64ca8398bb
commit 19ed26bbfc
2 changed files with 13 additions and 0 deletions
@@ -48,6 +48,13 @@ msgid ""
" </span>"
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"
@@ -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
# -------------------------------------------------------------------------