From 5632ad99e322cedf361922e7db9ec7a33ef59f3a Mon Sep 17 00:00:00 2001 From: pedrambiria Date: Mon, 17 Apr 2023 10:31:55 +0000 Subject: [PATCH] [FIX] pos_loyalty: use `float_compare` to compare points After this commit, we will be using float_compare function to compare points. This will ensure that any floating point errors are properly handled and that we receive correct responses from the `validate_coupon_programs` function. opw-3264681 closes odoo/odoo#118829 X-original-commit: 48013733a6e8b655cbc81211b1010e76102b9c2a Signed-off-by: Heinz Robin (rhe) Signed-off-by: Pedram Bi Ria (pebr) --- addons/pos_loyalty/models/pos_order.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/pos_loyalty/models/pos_order.py b/addons/pos_loyalty/models/pos_order.py index 621a79f6292..134097cb135 100644 --- a/addons/pos_loyalty/models/pos_order.py +++ b/addons/pos_loyalty/models/pos_order.py @@ -3,6 +3,7 @@ from collections import defaultdict from odoo import _, models +from odoo.tools import float_compare import base64 class PosOrder(models.Model): @@ -28,7 +29,7 @@ class PosOrder(models.Model): } } for coupon in coupons: - if (coupon.points + point_changes[coupon.id]) < 0: + if float_compare(coupon.points, -point_changes[coupon.id], 2) == -1: return { 'successful': False, 'payload': {