[FIX] point_of_sale: Prevent multiple cash payment method in PoS

Current behavior:
When creating a PoS config, it is possible to have multiple cash payment
method. Wich is not supported by the PoS.

opw-3030125

closes odoo/odoo#109331

X-original-commit: 7ba362b60a38a993fdeec920e6c90a754ddeb910
Signed-off-by: Trinh Jacky (trj) <trj@odoo.com>
Signed-off-by: Engels Robin (roen) <roen@odoo.com>
This commit is contained in:
roen-odoo
2023-01-06 16:34:23 +01:00
parent de7392a1b8
commit 44ce99ec9a
2 changed files with 14 additions and 0 deletions
@@ -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
@@ -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: