[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) <moc@odoo.com>
Signed-off-by: Pedram Bi Ria (pebr) <pebr@odoo.com>
This commit is contained in:
Pedram (pebr)
2024-02-12 10:44:46 +00:00
parent d0d2c2d973
commit 89074664bd
+3 -3
View File
@@ -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: