[MERGE] forward port branch saas-11.3 up to 7636a83eb68
This commit is contained in:
@@ -111,7 +111,8 @@ class SaleOrder(models.Model):
|
||||
return fixed_amount
|
||||
|
||||
def _get_lines_unit_prices(self):
|
||||
return [x.price_unit for x in self.order_line.filtered(lambda x: not x.is_reward_line)]
|
||||
# Unit prices tax included
|
||||
return [x.price_total / x.product_uom_qty for x in self.order_line.filtered(lambda x: not x.is_reward_line)]
|
||||
|
||||
def _get_reward_values_discount_percentage(self, program):
|
||||
discount_amount = 0
|
||||
@@ -123,7 +124,7 @@ class SaleOrder(models.Model):
|
||||
unit_prices = self._get_lines_unit_prices()
|
||||
discount_amount = (min(unit_prices) * (program.discount_percentage) / 100)
|
||||
if program.discount_apply_on == 'specific_product':
|
||||
discount_amount = sum([(x.price_total * x.product_uom_qty) * (program.discount_percentage / 100) for x in self.order_line.filtered(
|
||||
discount_amount = sum([x.price_total * (program.discount_percentage / 100) for x in self.order_line.filtered(
|
||||
lambda x: x.product_id == program.discount_specific_product_id)])
|
||||
if program.discount_max_amount and discount_amount > max_amount:
|
||||
discount_amount = max_amount
|
||||
|
||||
@@ -178,3 +178,11 @@ class TestSaleCouponProgramNumbers(TestSaleCouponCommon):
|
||||
order.recompute_coupon_lines()
|
||||
# (10x25) + (320 +15% tax) - (20% of (320 + 15% tax) = 250 + 368 - 73.6 = 544.4
|
||||
self.assertEqual(order.amount_total, 544.4, "We should only get reduction on ipad")
|
||||
sol1.product_uom_qty = 10
|
||||
order.recompute_coupon_lines()
|
||||
# (10x25) + (10x (320 +15% tax)) - (20% of (10x (320 + 15% tax))) - 2 free iPads = 250 + 3680 - 736 - 736 = 2458
|
||||
self.assertEqual(order.amount_total, 2458, "Changing ipad quantity should change discount amount correctly")
|
||||
|
||||
p_specific_product.discount_max_amount = 200
|
||||
order.recompute_coupon_lines()
|
||||
self.assertEqual(order.amount_total, 2994, "The discount should be limited to $200")
|
||||
|
||||
Reference in New Issue
Block a user