diff --git a/addons/point_of_sale/i18n/point_of_sale.pot b/addons/point_of_sale/i18n/point_of_sale.pot index cc5c41832de..701e441b302 100644 --- a/addons/point_of_sale/i18n/point_of_sale.pot +++ b/addons/point_of_sale/i18n/point_of_sale.pot @@ -6943,6 +6943,13 @@ msgid "" " Or you can add demo data for testing purpose. Please mind that this is an irreversible action." msgstr "" +#. module: point_of_sale +#. odoo-python +#: code:addons/point_of_sale/models/pos_config.py:0 +#, python-format +msgid "You can only have one cash payment method." +msgstr "" + #. module: point_of_sale #: code:addons/point_of_sale/models/pos_session.py:0 #, python-format diff --git a/addons/point_of_sale/models/pos_config.py b/addons/point_of_sale/models/pos_config.py index 42200fe2cb1..74a739515d0 100644 --- a/addons/point_of_sale/models/pos_config.py +++ b/addons/point_of_sale/models/pos_config.py @@ -180,6 +180,13 @@ class PosConfig(models.Model): for config in self: config.cash_control = bool(config.payment_method_ids.filtered('is_cash_count')) + @api.onchange('payment_method_ids') + def _check_cash_payment_method(self): + for config in self: + if len(config.payment_method_ids.filtered('is_cash_count')) > 1: + config.payment_method_ids = config.payment_method_ids._origin + raise ValidationError(_('You can only have one cash payment method.')) + @api.depends('company_id') def _compute_company_has_template(self): for config in self: