From ac5b316a4ee888a654a1462b2eeaaa1d68e69187 Mon Sep 17 00:00:00 2001 From: Danial Sheikhani Date: Wed, 30 Nov 2022 11:49:32 +0000 Subject: [PATCH] [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 --- addons/loyalty/models/loyalty_program.py | 8 +++++--- addons/loyalty/static/src/js/loyalty_list_view.js | 1 + addons/loyalty/static/src/xml/loyalty_templates.xml | 6 +++--- addons/loyalty/views/loyalty_reward_views.xml | 1 + 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/addons/loyalty/models/loyalty_program.py b/addons/loyalty/models/loyalty_program.py index dce5d2c3315..da8dc4c43b8 100644 --- a/addons/loyalty/models/loyalty_program.py +++ b/addons/loyalty/models/loyalty_program.py @@ -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 diff --git a/addons/loyalty/static/src/js/loyalty_list_view.js b/addons/loyalty/static/src/js/loyalty_list_view.js index 7eb321fcb9d..d467d4c7a8f 100644 --- a/addons/loyalty/static/src/js/loyalty_list_view.js +++ b/addons/loyalty/static/src/js/loyalty_list_view.js @@ -29,6 +29,7 @@ export class LoyaltyActionHelper extends Component { "loyalty.program", "create_from_template", [templateId], + {context: this.env.model.root.context}, ); if (!action) { return; diff --git a/addons/loyalty/static/src/xml/loyalty_templates.xml b/addons/loyalty/static/src/xml/loyalty_templates.xml index 5989a7aaf7e..e3ac08c9507 100644 --- a/addons/loyalty/static/src/xml/loyalty_templates.xml +++ b/addons/loyalty/static/src/xml/loyalty_templates.xml @@ -10,10 +10,10 @@
-
- -
+
+ +
diff --git a/addons/loyalty/views/loyalty_reward_views.xml b/addons/loyalty/views/loyalty_reward_views.xml index cb6b84ca586..1160b6ae49e 100644 --- a/addons/loyalty/views/loyalty_reward_views.xml +++ b/addons/loyalty/views/loyalty_reward_views.xml @@ -80,6 +80,7 @@ +