From e61ceb547705878c912dc72900ea4762792173e0 Mon Sep 17 00:00:00 2001
From: pedrambiria <pebr@odoo.com>
Date: Mon, 22 May 2023 09:10:06 +0000
Subject: [PATCH] [REV] point_of_sale: allow multiple cash payment methods in
 PoS

We are reverting this commit (f9da3590261b304f9c12f01f5800cec50faebc1a) because
it is not compliant to the stable policy and is blocking users that had more than one cash
payment methods in configuring their pos.

opw-3331677

closes odoo/odoo#121879

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
---
 addons/point_of_sale/i18n/point_of_sale.pot |  6 ------
 addons/point_of_sale/models/pos_config.py   |  7 -------
 addons/point_of_sale/tests/common.py        | 23 ++++++++++++---------
 3 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/addons/point_of_sale/i18n/point_of_sale.pot b/addons/point_of_sale/i18n/point_of_sale.pot
index fd92026ce743..57b0a09bae23 100644
--- a/addons/point_of_sale/i18n/point_of_sale.pot
+++ b/addons/point_of_sale/i18n/point_of_sale.pot
@@ -6738,12 +6738,6 @@ msgid ""
 "Would you like to proceed anyway?"
 msgstr ""
 
-#. module: point_of_sale
-#: 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/account_bank_statement.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 e6333a096618..5cfbe5b68c7f 100644
--- a/addons/point_of_sale/models/pos_config.py
+++ b/addons/point_of_sale/models/pos_config.py
@@ -188,13 +188,6 @@ 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('use_pricelist', 'available_pricelist_ids')
     def _compute_allowed_pricelist_ids(self):
         for config in self:
diff --git a/addons/point_of_sale/tests/common.py b/addons/point_of_sale/tests/common.py
index 1bdcd9a3b4d8..6aeebfdc33b7 100644
--- a/addons/point_of_sale/tests/common.py
+++ b/addons/point_of_sale/tests/common.py
@@ -332,16 +332,19 @@ class TestPoSCommon(ValuationReconciliationTestCommon):
             'outstanding_account_id': cls.outstanding_bank.id,
         })
 
-        new_config = cls.env['pos.config'].create({
-            'name': 'Shop Other',
-            'invoice_journal_id': other_invoice_journal.id,
-            'journal_id': other_sales_journal.id,
-            'use_pricelist': True,
-            'available_pricelist_ids': [(6, 0, [other_pricelist.id])],
-            'pricelist_id': other_pricelist.id,
-            'payment_method_ids': [(6, 0, [cls.cash_pm2.id, cls.bank_pm2.id])],
-        })
-        return new_config
+        new_config = Form(cls.env['pos.config'])
+        new_config.name = 'Shop Other'
+        new_config.invoice_journal_id = other_invoice_journal
+        new_config.journal_id = other_sales_journal
+        new_config.use_pricelist = True
+        new_config.available_pricelist_ids.clear()
+        new_config.available_pricelist_ids.add(other_pricelist)
+        new_config.pricelist_id = other_pricelist
+        new_config.payment_method_ids.clear()
+        new_config.payment_method_ids.add(cls.cash_pm2)
+        new_config.payment_method_ids.add(cls.bank_pm2)
+        config = new_config.save()
+        return config
 
     @classmethod
     def _create_categ_anglo(cls):
-- 
GitLab