From 8c77e1cfdb8f1a964e8428dbcb7315cde61d0a70 Mon Sep 17 00:00:00 2001 From: "Touati Djamel (otd)" Date: Fri, 12 Nov 2021 12:37:41 +0000 Subject: [PATCH] [FIX] {pos,sale}_gift_card: compute the gift card balance correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Steps to reproduce the bug: - Install POS - Go to the POS settings and enable “Gift Card” option - Create a new Gift card with initial amount of $50 - Open a new POS session > create an order of $50 and apply the gift card - Confirm the order > the order state becomes “paid” and the gift card balance is computed correctly: $0 Problem: Close the POS session, the order state becomes “done” and the balance is computed wrongly: $50 opw-2683523 closes odoo/odoo#79741 X-original-commit: 10f22a125a96d60fc5983531f6026ba325d08959 Signed-off-by: Joseph Caburnay (jcb) --- addons/pos_gift_card/models/gift_card.py | 2 +- addons/sale_gift_card/models/gift_card.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/pos_gift_card/models/gift_card.py b/addons/pos_gift_card/models/gift_card.py index 0f54772179d..7c7d93a8917 100644 --- a/addons/pos_gift_card/models/gift_card.py +++ b/addons/pos_gift_card/models/gift_card.py @@ -22,7 +22,7 @@ class GiftCard(models.Model): super()._compute_balance() for record in self: confirmed_line = record.redeem_pos_order_line_ids.filtered( - lambda l: l.order_id.state == "paid" + lambda l: l.order_id.state in ('paid', 'done', 'invoiced') ) balance = record.balance if confirmed_line: diff --git a/addons/sale_gift_card/models/gift_card.py b/addons/sale_gift_card/models/gift_card.py index 1949f03e3dd..8bc5568b741 100644 --- a/addons/sale_gift_card/models/gift_card.py +++ b/addons/sale_gift_card/models/gift_card.py @@ -15,7 +15,7 @@ class GiftCard(models.Model): def _compute_balance(self): super()._compute_balance() for record in self: - confirmed_line = record.redeem_line_ids.filtered(lambda l: l.state == 'sale') + confirmed_line = record.redeem_line_ids.filtered(lambda l: l.state in ('sale', 'done')) balance = record.balance if confirmed_line: balance -= sum(confirmed_line.mapped(