From 89074664bdae56f6da7e53dd00880277997d9abb Mon Sep 17 00:00:00 2001 From: "Pedram (pebr)" Date: Thu, 18 Jan 2024 11:12:05 +0000 Subject: [PATCH] [FIX] pos_loyalty: allow Gift Cards to be usable by any customer Prior to this commit, Gift cards assigned to a specific partner were restricted for use only by that partner. This commit rectifies the issue, enabling Gift cards to be usable by any customer as intended. opw-3689391 closes odoo/odoo#153507 X-original-commit: 15c79c3f46bcc6787efc950bd3a9a122b298f919 Signed-off-by: Christophe Monniez (moc) Signed-off-by: Pedram Bi Ria (pebr) --- addons/pos_loyalty/models/pos_config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/pos_loyalty/models/pos_config.py b/addons/pos_loyalty/models/pos_config.py index bb91c17b5f7..a76b7a8d5dd 100644 --- a/addons/pos_loyalty/models/pos_config.py +++ b/addons/pos_loyalty/models/pos_config.py @@ -73,11 +73,11 @@ class PosConfig(models.Model): def use_coupon_code(self, code, creation_date, partner_id, pricelist_id): self.ensure_one() - # Ordering by partner id to use the first assigned to the partner in case multiple coupons have the same code - # it could happen with loyalty programs using a code # Points desc so that in coupon mode one could use a coupon multiple times coupon = self.env['loyalty.card'].search( - [('program_id', 'in', self._get_program_ids().ids), ('partner_id', 'in', (False, partner_id)), ('code', '=', code)], + [('program_id', 'in', self._get_program_ids().ids), + '|', ('partner_id', 'in', (False, partner_id)), ('program_type', '=', 'gift_card'), + ('code', '=', code)], order='partner_id, points desc', limit=1) program = coupon.program_id if not coupon or not program.active: