[MERGE] forward port branch saas-15 up to 7d49f2f192c

This commit is contained in:
Christophe Simonis
2018-03-29 18:47:19 +02:00
2 changed files with 16 additions and 1 deletions
+2 -1
View File
@@ -41,7 +41,8 @@ class SaleOrder(models.Model):
}
def _get_lines_unit_prices(self):
return [x.price_unit for x in self.order_line.filtered(lambda x: not x.is_delivery and not x.program_id)]
# Unit prices tax included
return [x.price_total / x.product_uom_qty for x in self.order_line.filtered(lambda x: not x.is_delivery and not x.is_reward_line)]
class SalesOrderLine(models.Model):
_inherit = "sale.order.line"
+14
View File
@@ -186,3 +186,17 @@ class TestSaleCouponProgramRules(TestSaleCouponCommon):
self.assertEqual(order.reward_amount, -20 -290.91)
self.assertEqual(sum([line.price_total for line in order._get_no_effect_on_threshold_lines()]), 0)
self.assertEqual(order.amount_untaxed, 872.73)
p_specific_product = self.env['sale.coupon.program'].create({
'name': '20% reduction on ipad in cart',
'promo_code_usage': 'no_code_needed',
'reward_type': 'discount',
'program_type': 'promotion_program',
'discount_type': 'percentage',
'discount_percentage': 20.0,
'discount_apply_on': 'cheapest_product',
})
p_specific_product.discount_apply_on = 'cheapest_product'
order.recompute_coupon_lines()
# 872.73 - (20% of 1 iPad) = 872.73 - 64 = 808.73
self.assertEqual(order.amount_untaxed, 808.73, "One iPad should be discounted by 20%")