This commit is contained in:
gsinghpal
2026-05-12 09:08:34 -04:00
parent 01a46e33e2
commit b07f771d98
4 changed files with 36 additions and 2 deletions

View File

@@ -1,2 +1,2 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from . import models

View File

@@ -4,7 +4,7 @@
{ {
"name": "Fusion Theme Switcher", "name": "Fusion Theme Switcher",
"version": "19.0.1.0.1", "version": "19.0.1.1.0",
"category": "Productivity", "category": "Productivity",
"summary": "Backend header toggle for Odoo Enterprise light and dark mode.", "summary": "Backend header toggle for Odoo Enterprise light and dark mode.",
"description": """ "description": """

View File

@@ -0,0 +1 @@
from . import res_users_settings

View File

@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# Copyright 2026 Nexa Systems Inc.
# License OPL-1 (Odoo Proprietary License v1.0)
"""Coerce a missing color_scheme to the default on create/write.
`web_enterprise` declares `color_scheme` as required with default 'system',
and the DB column is NOT NULL. It also adds a radio widget for
`res.users.color_scheme` (a related field) to the user form. For a brand-new
user the underlying `res.users.settings` record doesn't exist yet, so the
widget loads with no value and submitting the form propagates
`color_scheme=False` into the eventual settings create/write — which trips the
NOT NULL constraint and surfaces as "Missing required value for the field
'Color Scheme'".
Treat a falsy color_scheme as 'omit' so the field's own default applies.
"""
from odoo import api, models
class ResUsersSettings(models.Model):
_inherit = "res.users.settings"
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if "color_scheme" in vals and not vals["color_scheme"]:
vals["color_scheme"] = "system"
return super().create(vals_list)
def write(self, vals):
if "color_scheme" in vals and not vals["color_scheme"]:
vals = {**vals, "color_scheme": "system"}
return super().write(vals)