[FIX] sale_loyalty: check coupon partner
Steps to reproduce:
- create a "gift card" with a specific customer;
- use gift card code with any customer (Sales and/or eCommerce app).
Issue:
The coupon is validated.
Cause:
There is no partner verification when applying a coupon.
opw-3027251
closes odoo/odoo#103673
X-original-commit: 092d652b1f38b804657b6e1d383a157615cf9487
Signed-off-by: Grazioso Andrea (agr) <agr@odoo.com>
Signed-off-by: Lefebvre Thomas (thle) <thle@odoo.com>
This commit is contained in:
@@ -182,6 +182,12 @@ msgstr ""
|
||||
msgid "ID"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale_loyalty
|
||||
#: code:addons/sale_loyalty/models/sale_order.py:0
|
||||
#, python-format
|
||||
msgid "Invalid partner."
|
||||
msgstr ""
|
||||
|
||||
#. module: sale_loyalty
|
||||
#: code:addons/sale_loyalty/models/sale_order.py:0
|
||||
#, python-format
|
||||
|
||||
@@ -947,6 +947,8 @@ class SaleOrder(models.Model):
|
||||
not coupon.program_id.reward_ids or\
|
||||
not coupon.program_id.filtered_domain(self._get_program_domain()):
|
||||
return {'error': _('This code is invalid (%s).', code), 'not_found': True}
|
||||
elif coupon.partner_id and coupon.partner_id != self.partner_id:
|
||||
return {'error': _('Invalid partner.')}
|
||||
elif coupon.expiration_date and coupon.expiration_date < fields.Date.today():
|
||||
return {'error': _('This coupon is expired.')}
|
||||
elif coupon.points < min(coupon.program_id.reward_ids.mapped('required_points')):
|
||||
|
||||
Reference in New Issue
Block a user