diff --git a/addons/loyalty/i18n/loyalty.pot b/addons/loyalty/i18n/loyalty.pot index 392e925514d..f98eee2aa69 100644 --- a/addons/loyalty/i18n/loyalty.pot +++ b/addons/loyalty/i18n/loyalty.pot @@ -1419,6 +1419,11 @@ msgstr "" msgid "Product Variant" msgstr "" +#. module: loyalty +#: model:ir.model.fields,help:loyalty.field_loyalty_program__discount_product_id +msgid "Product used in the sales order to apply the discount." +msgstr "" + #. module: loyalty #: model:ir.model.fields,help:loyalty.field_loyalty_reward__discount_line_product_id msgid "" diff --git a/addons/loyalty/models/loyalty_program.py b/addons/loyalty/models/loyalty_program.py index a15aa627788..b8d7302199a 100644 --- a/addons/loyalty/models/loyalty_program.py +++ b/addons/loyalty/models/loyalty_program.py @@ -91,6 +91,14 @@ class LoyaltyProgram(models.Model): is_nominative = fields.Boolean(compute='_compute_is_nominative') is_payment_program = fields.Boolean(compute='_compute_is_payment_program') + payment_program_discount_product_id = fields.Many2one( + 'product.product', + string='Discount Product', + compute='_compute_payment_program_discount_product_id', + readonly=True, + help="Product used in the sales order to apply the discount." + ) + # Technical field used for a label available_on = fields.Boolean("Available On", store=False, help=""" @@ -183,6 +191,14 @@ class LoyaltyProgram(models.Model): for program in self: program.is_payment_program = program.program_type in ('gift_card', 'ewallet') + @api.depends('reward_ids.discount_line_product_id') + def _compute_payment_program_discount_product_id(self): + for program in self: + if program.is_payment_program: + program.payment_program_discount_product_id = program.reward_ids[0].discount_line_product_id + else: + program.payment_program_discount_product_id = False + @api.model def _program_items_name(self): return { diff --git a/addons/loyalty/views/loyalty_program_views.xml b/addons/loyalty/views/loyalty_program_views.xml index 4a3267a3cd5..04e30d0ebed 100644 --- a/addons/loyalty/views/loyalty_program_views.xml +++ b/addons/loyalty/views/loyalty_program_views.xml @@ -82,6 +82,7 @@ + diff --git a/addons/loyalty/views/loyalty_reward_views.xml b/addons/loyalty/views/loyalty_reward_views.xml index e9fa7028472..f43dfb314e3 100644 --- a/addons/loyalty/views/loyalty_reward_views.xml +++ b/addons/loyalty/views/loyalty_reward_views.xml @@ -55,6 +55,7 @@ +