Skip to content

Commit

Permalink
[FIX] loyalty_partner_applicability: Set default value for partner do…
Browse files Browse the repository at this point in the history
…main rule

It is necessary to set the default value, in this case "[ ]" to the rule_partners_domain field, overwriting the computed method "_program_type_default_values" that sets the default values depending on the type of program, because when creating a new program, these default rules are defined and the rule_partners_domain field, not being contemplated, its value will be "False", which cannot be interpreted as a correct domain. To avoid this error, the value is added to the rules defined by default.

TT44344
  • Loading branch information
pilarvargas-tecnativa committed Dec 1, 2023
1 parent e2e702a commit c1e136c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions loyalty_partner_applicability/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import loyalty_program
from . import loyalty_rule
from . import res_config_settings
21 changes: 21 additions & 0 deletions loyalty_partner_applicability/models/loyalty_program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2023 Tecnativa - Pilar Vargas
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
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()
program_types_to_update = [
"promotion",
"loyalty",
"promo_code",
"buy_x_get_y",
"next_order_coupons",
]
for program_type in program_types_to_update:
res[program_type]["rule_ids"][1][2].update({"rule_partners_domain": "[]"})
return res

0 comments on commit c1e136c

Please sign in to comment.