Merge pull request #75 from expsa/odex_theme_branch

fix: Correct active template handling in create method to ensure prop…
This commit is contained in:
Tahir Hassan 2026-01-06 10:28:01 +04:00 committed by GitHub
commit a5591dfaf6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 5 deletions

View File

@ -111,14 +111,13 @@ class ExpertLoginTemplate(models.Model):
def create(self, vals):
"""Ensure only one template is active at a time"""
# If no active value is set, default to False (don't auto-activate new templates)
if 'active' not in vals[0]:
vals[0]['active'] = False
if 'active' not in vals:
vals['active'] = False
# Only deactivate others if this one is being set to active
print(vals[0])
if vals[0].get('active'):
if vals.get('active'):
# Deactivate all other templates (excluding the one being created)
self.search([('active', '=', True)]).write({'active': False})
return super(ExpertLoginTemplate, self).create(vals[0])
return super(ExpertLoginTemplate, self).create(vals)
def write(self, vals):
"""Ensure only one template is active at a time"""