diff --git a/addons/point_of_sale/i18n/point_of_sale.pot b/addons/point_of_sale/i18n/point_of_sale.pot index d6080616d14..8bfd1ca91c4 100644 --- a/addons/point_of_sale/i18n/point_of_sale.pot +++ b/addons/point_of_sale/i18n/point_of_sale.pot @@ -5982,6 +5982,13 @@ msgid "" " specific tax rates." msgstr "" +#. module: point_of_sale +#: code:addons/point_of_sale/models/account_journal.py:0 +#, python-format +msgid "" +"This journal is associated with a payment method. You cannot modify its type" +msgstr "" + #. module: point_of_sale #. openerp-web #: code:addons/point_of_sale/static/src/js/ChromeWidgets/DebugWidget.js:0 diff --git a/addons/point_of_sale/models/account_journal.py b/addons/point_of_sale/models/account_journal.py index 3e41f4476b8..c511384884f 100644 --- a/addons/point_of_sale/models/account_journal.py +++ b/addons/point_of_sale/models/account_journal.py @@ -1,10 +1,16 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. # Copyright (C) 2004-2008 PC Solutions (). All Rights Reserved -from odoo import fields, models, api - +from odoo import fields, models, api, _ +from odoo.exceptions import ValidationError class AccountJournal(models.Model): _inherit = 'account.journal' pos_payment_method_ids = fields.One2many('pos.payment.method', 'journal_id', string='Point of Sale Payment Methods') + + @api.constrains('type') + def _check_type(self): + methods = self.env['pos.payment.method'].sudo().search([("journal_id", "in", self.ids)]) + if methods: + raise ValidationError(_("This journal is associated with a payment method. You cannot modify its type"))