[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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user