This commit improves some messages and usability for loyalty and its submodules: - Coupons should not be restricted to the partner assigned to them anymore - Merged "I have a promo code" and "Use a gift card" into a single toggle - Boolean fields have been added to each app to disable them where we don't want them. - Reduced the size of coupon codes This means that we increase the risk of collision which should be handled by the model as well now. Creating a coupon with an existing code will retry the creation (up to 10 times) until the coupon is indeed created. - Make it clearer in the coupon generation wizard that an email will be sent to the customer. - Reintroduce coupon/gift card details on sale order lines in eCommerce which was wrongfully removed. - Remove the "on product with taxes: " message on order lines when the amount is not split between taxes or if the tax message would be empty. - Make it possible for some error messages to be displayed as warning instead of errors - Split program types in two menuitems, one for promotions discount loyalty etc and one for gift cards and ewallet, the latter has simplified views. - Views overall have been reviewed to make it easier to understand how to programs work. New program types have also been added. TaskId-2951413 Part-of: odoo/odoo#99023 Co-authored-by: William Braeckman <wbr@odoo.com>
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import _, api, models
|
|
|
|
class LoyaltyProgram(models.Model):
|
|
_inherit = 'loyalty.program'
|
|
|
|
@api.model
|
|
def _program_type_default_values(self):
|
|
res = super()._program_type_default_values()
|
|
# Add a loyalty reward for free shipping
|
|
if 'loyalty' in res:
|
|
res['loyalty']['reward_ids'].append((0, 0, {
|
|
'reward_type': 'shipping',
|
|
'required_points': 100,
|
|
}))
|
|
return res
|
|
|
|
@api.model
|
|
def get_program_templates(self):
|
|
# Override 'promotion' template to say free shipping
|
|
res = super().get_program_templates()
|
|
if 'promotion' in res:
|
|
res['promotion']['description'] = _("Automatic promotion: free shipping on orders higher than $50")
|
|
return res
|
|
|
|
@api.model
|
|
def _get_template_values(self):
|
|
res = super()._get_template_values()
|
|
if 'promotion' in res:
|
|
res['promotion']['reward_ids'] = [(5, 0, 0), (0, 0, {
|
|
'reward_type': 'shipping',
|
|
})]
|
|
return res
|