summaryrefslogtreecommitdiff
path: root/tests/test_program_numbers.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-09-28 19:15:14 +0200
committerChristophe Simonis <chs@odoo.com>2018-09-28 19:15:14 +0200
commit9c457eb0d5fd5d62f6e79302ed67ab3ead6fcb33 (patch)
tree4d200e46cb1d34720c00f60376da079e43955e84 /tests/test_program_numbers.py
parent15f5a7fae79ac92202dd88c800800e9e29ca96f6 (diff)
parentaf0e47f42f89d624b4c0a74fc2ebb7eb1889da54 (diff)
[MERGE] forward port branch saas-14 up to 285a68d2357
Diffstat (limited to 'tests/test_program_numbers.py')
-rw-r--r--tests/test_program_numbers.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/test_program_numbers.py b/tests/test_program_numbers.py
index 39f15fffb0e..01da22c1de4 100644
--- a/tests/test_program_numbers.py
+++ b/tests/test_program_numbers.py
@@ -453,3 +453,30 @@ class TestSaleCouponProgramNumbers(TestSaleCouponCommon):
self.env['sale.coupon.apply.code'].with_context(active_id=order.id).create({
'coupon_code': 'test_10pc'
}).process_coupon()
+
+ def test_program_fixed_price(self):
+ # Check fixed amount discount
+ order = self.empty_order
+ fixed_amount_program = self.env['sale.coupon.program'].create({
+ 'name': '$249 discount',
+ 'promo_code_usage': 'no_code_needed',
+ 'program_type': 'promotion_program',
+ 'discount_type': 'fixed_amount',
+ 'discount_fixed_amount': 249.0,
+ })
+ sol1 = self.env['sale.order.line'].create({
+ 'product_id': self.computerCase.id,
+ 'name': 'Computer Case',
+ 'product_uom_qty': 1.0,
+ 'order_id': order.id,
+ })
+ order.recompute_coupon_lines()
+ self.assertEqual(order.amount_total, 0, "Total should be null. The fixed amount discount is higher than the SO total, it should be reduced to the SO total")
+ self.assertEqual(len(order.order_line.ids), 2, "There should be the product line and the reward line")
+ sol1.product_uom_qty = 17
+ order.recompute_coupon_lines()
+ self.assertEqual(order.amount_total, 176, "Fixed amount discount should be totally deduced")
+ self.assertEqual(len(order.order_line.ids), 2, "Number of lines should be unchanged as we just recompute the reward line")
+ fixed_amount_program.write({'active': False}) # Check archived product will remove discount lines on recompute
+ order.recompute_coupon_lines()
+ self.assertEqual(len(order.order_line.ids), 1, "Archiving the program should remove the program reward line")