feat: bypass loyalty program state reset logic during module installation and explicit context triggers

This commit is contained in:
Suherdy Yacob 2026-06-08 21:20:22 +07:00
parent 15917ee277
commit f9233da337

View File

@ -50,6 +50,12 @@ class LoyaltyProgram(models.Model):
if len(vals) == 1 and 'state' in vals:
return super().write(vals)
# Skip reset logic if Odoo is installing/upgrading modules or explicitly bypassed
if (self.env.context.get('install_mode')
or self.env.context.get('module')
or self.env.context.get('no_marketing_reset')):
return super().write(vals)
# For modifications, check if they are in pending/approved state
programs_to_reset = self.filtered(lambda p: p.state in ['pending', 'approved'])
if programs_to_reset: