diff options
| author | Romain Derie <rde@odoo.com> | 2018-11-12 18:06:57 +0100 |
|---|---|---|
| committer | Romain Derie <rde@odoo.com> | 2018-11-15 15:57:17 +0100 |
| commit | 63131c258486002831cfbfa980214233fad201f9 (patch) | |
| tree | c0de2648ae05b87456cd57de93f33a42ad325372 /tests/test_program_rules.py | |
| parent | 231669e33269257d1539c9a1f13189a332dda668 (diff) | |
[FIX] sale_coupon: reset no more eligible applied coupon to Valid state
Before this commit:
When a coupon_program's coupon was giving a reward on a SO and then the
recompute was removing that reward (eg the SO did not met the requirements
anymore) the coupon would not be reset and would be lost.
Now:
If a coupon's reward got removed for some reason, the coupon got reset to a
valid state (`new`) so it can be used again.
Step to reproduce:
- Generate a coupon from a coupon program that needs requirements (eg $300)
- Add that coupon to a SO that has a total over $300
- Coupon is set as `used` and the reward is granted
- Remove some products to set the SO total below $300
- Recompute coupon, the reward is correctly removed but the coupon is still
set as `used` so it won't be usable again and is basically lost.
Closes #3062
Diffstat (limited to 'tests/test_program_rules.py')
| -rw-r--r-- | tests/test_program_rules.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/tests/test_program_rules.py b/tests/test_program_rules.py index 5339e00cb05..727f71bcadc 100644 --- a/tests/test_program_rules.py +++ b/tests/test_program_rules.py @@ -233,8 +233,10 @@ class TestProgramRules(TestSaleCouponCommon): order.recompute_coupon_lines() self.assertEqual(len(order.order_line.ids), 3, "The order should contains the Product A line, the Product B line and the discount line") + self.assertEqual(coupon.state, 'used', "The coupon should be set to Consumed as it has been used") sol1.product_uom_qty = 2 order.recompute_coupon_lines() self.assertEqual(len(order.order_line.ids), 2, "The discount line should have been removed as we don't meet the program requirements") + self.assertEqual(coupon.state, 'new', "The coupon should be reset to Valid as it's reward got removed") |
