summaryrefslogtreecommitdiff
path: root/tests/test_program_rules.py
diff options
context:
space:
mode:
authorYannick Tivisse <yti@odoo.com>2017-06-21 10:24:02 +0200
committerYannick Tivisse <yti@odoo.com>2017-06-21 15:55:27 +0200
commit8f6ec5875750c355a6bc77ca5e866f440bf8c4f6 (patch)
treea73e81b6932f4cce0a280eb051f7aa6e10d7b95f /tests/test_program_rules.py
parent3ed9b783dc8ae9c33579b6c92fe4d2ea074b20a0 (diff)
[FIX] sale_coupon: Don't update automatic rewards on the fly
Purpose ======= Currently we are updating the coupon rewards on the fly when creating/modifying/deleting a sales order line. To avoid multiple searches on res_partners and product to know whether the customer/product is valid on the sale coupon program, we store the applicable customers and products on the program according to the domain defined on it. This brings 2 issues: - The customers/products stored on the program are not updated (Was the original spec) - The checks are numerous and maybe overkill for the given results Specification ============= - Don't recompute the reward lines on SO modifications. Add a button to compute the line by hand and make an automatic compute on the SO validation or on the page shop/payment. - When recomputing the reward lines, make a search on the res_partners and products instead. Now that the action is not triggered so often we can afford to make a search. - Don't use the fields rule_partners_domain and rule_products_domain. This should be removed in master. - The field is_public_included is useless now. And we decided to make the coupon available for all the partners if they fit the domain on the program.
Diffstat (limited to 'tests/test_program_rules.py')
-rw-r--r--tests/test_program_rules.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/test_program_rules.py b/tests/test_program_rules.py
index 35e30924d49..17018dd49fd 100644
--- a/tests/test_program_rules.py
+++ b/tests/test_program_rules.py
@@ -30,6 +30,7 @@ class TestProgramRules(TestSaleCouponCommon):
'product_uom_qty': 1.0,
})
]})
+ order.recompute_coupon_lines()
self.assertEqual(len(order.order_line.ids), 3, "The promo offert should have been applied as the partner is correct, the discount is not created")
order = self.env['sale.order'].create({'partner_id': self.env.ref('base.res_partner_1').id})
@@ -47,6 +48,7 @@ class TestProgramRules(TestSaleCouponCommon):
'product_uom_qty': 1.0,
})
]})
+ order.recompute_coupon_lines()
self.assertEqual(len(order.order_line.ids), 2, "The promo offert shouldn't have been applied, the discount is created")
def test_program_rules_minimum_purchased_amount(self):
@@ -72,6 +74,7 @@ class TestProgramRules(TestSaleCouponCommon):
'product_uom_qty': 1.0,
})
]})
+ order.recompute_coupon_lines()
self.assertEqual(len(order.order_line.ids), 2, "The promo offert shouldn't have been applied as the purchased amount is not enough")
order = self.env['sale.order'].create({'partner_id': self.steve.id})
@@ -89,6 +92,7 @@ class TestProgramRules(TestSaleCouponCommon):
'product_uom_qty': 1.0,
})
]})
+ order.recompute_coupon_lines()
self.assertEqual(len(order.order_line.ids), 3, "The promo offert should have been applied as the purchased amount is enough")
def test_program_rules_validity_dates_and_uses(self):
@@ -115,6 +119,7 @@ class TestProgramRules(TestSaleCouponCommon):
'product_uom_qty': 1.0,
})
]})
+ order.recompute_coupon_lines()
self.assertEqual(len(order.order_line.ids), 2, "The promo offert shouldn't have been applied we're not between the validity dates")
self.immediate_promotion_program.write({
@@ -136,6 +141,7 @@ class TestProgramRules(TestSaleCouponCommon):
'product_uom_qty': 1.0,
})
]})
+ order.recompute_coupon_lines()
self.assertEqual(len(order.order_line.ids), 3, "The promo offert should have been applied as we're between the validity dates")
order = self.env['sale.order'].create({'partner_id': self.env.ref('base.res_partner_1').id})
order.write({'order_line': [
@@ -152,4 +158,5 @@ class TestProgramRules(TestSaleCouponCommon):
'product_uom_qty': 1.0,
})
]})
+ order.recompute_coupon_lines()
self.assertEqual(len(order.order_line.ids), 2, "The promo offert shouldn't have been applied as the number of uses is exceeded")