diff options
| author | Romain Derie <rde@odoo.com> | 2018-09-28 14:07:55 +0200 |
|---|---|---|
| committer | Romain Derie <rde@odoo.com> | 2018-09-28 18:14:10 +0200 |
| commit | af0e47f42f89d624b4c0a74fc2ebb7eb1889da54 (patch) | |
| tree | 183f9daf7c16d645fa1caf2529117f326ae15f0d /tests/test_program_numbers.py | |
| parent | 85c89c300aba1936cb032e9c89a6a58f6d9577ef (diff) | |
[FIX] sale_coupon: compute fixed amount as such
Commit 092200073 broke the discount computation for discount of type
fixed_amount. Indeed the appropriate method was not called anymore and such
discount type would be computed as percentage discount with default value of
10% (field default for percentage).
opw-1888484
Diffstat (limited to 'tests/test_program_numbers.py')
| -rw-r--r-- | tests/test_program_numbers.py | 27 |
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") |
