summaryrefslogtreecommitdiff
path: root/tests/test_program_numbers.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-09-28 19:17:34 +0200
committerChristophe Simonis <chs@odoo.com>2018-09-28 19:17:34 +0200
commitcfca60d422a19e5111b92bb9a63a720c93f15d90 (patch)
treebb24e9cdf8593d7e4f0f89fe5bebd47198c4f114 /tests/test_program_numbers.py
parent6b5aadc7ce95282ae4bcca996d2e15efc89d8f6b (diff)
parent9c457eb0d5fd5d62f6e79302ed67ab3ead6fcb33 (diff)
[MERGE] forward port branch saas-15 up to ed3eff1427c
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")