[FIX] sale_loyalty: round real points for coupon
`_get_real_points_for_coupon` subtracts several floats which can result in rounding errors when a comparison is made in `action_confirm` that checks if the result is smaller than 0. If the result is something like -1 * 10^-14, Odoo will tell the user the coupon is invalid, which is false. To prevent this from happening, we round according to the associated currency of the points. opw-3120442 closes odoo/odoo#112995 X-original-commit: 59c43f5cc460f311388540558e0fb0731b02cbc2 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
@@ -494,6 +494,7 @@ class SaleOrder(models.Model):
|
||||
points += self.coupon_point_ids.filtered(lambda p: p.coupon_id == coupon).points
|
||||
# Points already used by rewards
|
||||
points -= sum(self.order_line.filtered(lambda l: l.coupon_id == coupon).mapped('points_cost'))
|
||||
points = coupon.currency_id.round(points)
|
||||
return points
|
||||
|
||||
def _add_points_for_coupon(self, coupon_points):
|
||||
|
||||
Reference in New Issue
Block a user