[FIX] loyalty: add link to discout products in loyalty.program form view
A customer has a gift card product linked to a specific income account. When sold, the income account associated with the gift card product is credited correctly. The issue arises when the gift card is consumed within a sales order. An order line is added using a "dummy product" to indicate the gift card's usage (one dummy product is created for each loyalty program). Due to this, when an account move is created from the sale order, the income account defined on the dummy product is used instead of the one on the gift card product. This leads to the wrong income account being debited, causing unbalanced accounting entries. There's currently no way to link back to the original gift card product from a `loyalty.card` record. Because of this, the system cannot identify the correct income account to debit. Fixing this would require adding a new field, which we can't do in stable. A potential workaround is to find the dummy product and set the income account to the same as the gift card product. However, with one dummy product for each `loyalty.program`, all named "Gift Card", finding the right dummy product is difficult. This commit aims to simplify the workaround by adding a link to the associated dummy product on the `loyalty.program` form view. This change should ease the process of finding and modifying the correct dummy product, thus mitigating the issue in the current stable version. opw-3239720 opw-3373287 closes odoo/odoo#133461 X-original-commit: 767eccb122055cd9a474ce5110cb7296eb9ef4c2 Signed-off-by: Séna Serge Nshimiyimana (sesn) <sesn@odoo.com>
This commit is contained in:
@@ -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 ""
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -82,6 +82,7 @@
|
||||
</div>
|
||||
<field name="trigger_product_ids" string="Gift Card Products" widget="many2many_tags" invisible="program_type != 'gift_card'"/>
|
||||
<field name="trigger_product_ids" string="eWallet Products" widget="many2many_tags" invisible="program_type != 'ewallet'"/>
|
||||
<field name="payment_program_discount_product_id" groups="base.group_no_one" invisible="program_type not in ('gift_card', 'ewallet')"/>
|
||||
<field name="mail_template_id" invisible="program_type not in ('gift_card', 'ewallet')"/>
|
||||
<field name="currency_id"/>
|
||||
<field name="currency_symbol" invisible="1"/>
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
</group>
|
||||
<group>
|
||||
<field name="description" string="Description on order"/>
|
||||
<field name="discount_line_product_id" string="Discount product" groups="base.group_no_one"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user