diff options
| author | nie <nie@odoo.com> | 2020-12-23 15:40:43 +0000 |
|---|---|---|
| committer | nie <nie@odoo.com> | 2020-12-28 09:04:14 +0000 |
| commit | d31a86cead03623c375f4162324a6d1872cad6a3 (patch) | |
| tree | dba4b48a31296c16e7c9f5c57a1c35f1fe75361b /addons/coupon | |
| parent | f545a385d2b2fde260e552dc3d13ab6f9246759e (diff) | |
[FIX] coupon: public user cannot use promo code with edited rule
Steps:
- Install eCommerce
- Go to Website > Products > Promotion Programs
- Create a promotion program with a filter Based on Customers and a promotion code
- Save
- Edit the new program and clear the filter Based on Customers
- Save again
- Log out and go to the shop
- Add an article to your cart and click "View Cart"
- Click "I have a promo code"
- Apply the promo code you created earlier
Bug:
The promo code is not accepted.
Explanation:
When the filter Based on Customers is cleared, `[]` is written on the program rule. This makes the app search for a partner with id = 4 (Public User). Since this user is not active, the search returns no results and, therefore, forbids the user from using the promo code.
This works flawlessly when you create a promotion program with no filters as they are initialized with `NULL` and a `NULL` filter always returns `True`.
opw:2419796
closes odoo/odoo#63811
X-original-commit: eb0e1f4e21b24a6920469dc35f6fc31c4a670750
Signed-off-by: backspac <backspac@users.noreply.github.com>
Diffstat (limited to 'addons/coupon')
| -rw-r--r-- | addons/coupon/models/coupon_program.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/addons/coupon/models/coupon_program.py b/addons/coupon/models/coupon_program.py index 7fa0c3ef004..b61bccc560d 100644 --- a/addons/coupon/models/coupon_program.py +++ b/addons/coupon/models/coupon_program.py @@ -133,7 +133,7 @@ class CouponProgram(models.Model): return self.currency_id._convert(self[field], currency_to, self.company_id, fields.Date.today()) def _is_valid_partner(self, partner): - if self.rule_partners_domain: + if self.rule_partners_domain and self.rule_partners_domain != '[]': domain = ast.literal_eval(self.rule_partners_domain) + [('id', '=', partner.id)] return bool(self.env['res.partner'].search_count(domain)) else: |
