[FIX] loyalty: coupon loyalty program issues

This commit fixes a few remaining bugs in loyalty:
- misplaced use of ewallet and gift view for discount program types;
- wrong context when creating a gift card (got discount and coupon);
- wrong options to program type when creating a loyalty card;
- product tag was mandatory in reward eventhough a reward product is
assigned.

task-3015891

X-original-commit: 440a853b01dbcc67ad926487764682a5c68c2c8b
Part-of: odoo/odoo#129115
This commit is contained in:
Danial Sheikhani
2023-07-20 13:07:10 +02:00
committed by Valentin Vallaeys (vava)
parent 87e4216174
commit ac5b316a4e
4 changed files with 10 additions and 6 deletions
+5 -3
View File
@@ -502,10 +502,12 @@ class LoyaltyProgram(models.Model):
program = self.create(template_values[template_id])
action = {}
if self.env.context.get('menu_type') == 'gift_ewallet':
action = self.env['ir.actions.act_window']._for_xml_id('loyalty.loyalty_program_discount_loyalty_action')
else:
action = self.env['ir.actions.act_window']._for_xml_id('loyalty.loyalty_program_gift_ewallet_action')
action['views'] = [[False, 'form']]
action['views'] = [[False, 'form']]
else:
action = self.env['ir.actions.act_window']._for_xml_id('loyalty.loyalty_program_discount_loyalty_action')
view_id = self.env.ref('loyalty.loyalty_program_view_form').id
action['views'] = [[view_id, 'form']]
action['view_mode'] = 'form'
action['res_id'] = program.id
return action
@@ -29,6 +29,7 @@ export class LoyaltyActionHelper extends Component {
"loyalty.program",
"create_from_template",
[templateId],
{context: this.env.model.root.context},
);
if (!action) {
return;
@@ -10,10 +10,10 @@
<t t-name="loyalty.LoyaltyActionHelper" owl="1">
<div class="o_view_nocontent">
<div class="o_nocontent_help">
<t t-out="props.noContentHelp"/>
</div>
<div class="container">
<div class="o_nocontent_help">
<t t-out="props.noContentHelp"/>
</div>
<div class="row justify-content-center loyalty-templates-container">
<t t-foreach="Object.entries(loyaltyTemplateData)" t-as="data" t-key="data[0]">
<t t-set="loyalty_el_icon" t-value="data[1].icon"/>
@@ -80,6 +80,7 @@
<field name="discount_max_amount"/>
<field name="discount_line_product_id"/>
<field name="reward_product_id"/>
<field name="reward_product_ids"/>
<field name="reward_product_tag_id"/>
<field name="multi_product"/>
<field name="reward_product_qty"/>