From b07f771d98945e4aa05948d12dc6872a8e49c8f7 Mon Sep 17 00:00:00 2001 From: gsinghpal Date: Tue, 12 May 2026 09:08:34 -0400 Subject: [PATCH] changes --- fusion_theme_switcher/__init__.py | 2 +- fusion_theme_switcher/__manifest__.py | 2 +- fusion_theme_switcher/models/__init__.py | 1 + .../models/res_users_settings.py | 33 +++++++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 fusion_theme_switcher/models/__init__.py create mode 100644 fusion_theme_switcher/models/res_users_settings.py diff --git a/fusion_theme_switcher/__init__.py b/fusion_theme_switcher/__init__.py index 633f8661..a0fdc10f 100644 --- a/fusion_theme_switcher/__init__.py +++ b/fusion_theme_switcher/__init__.py @@ -1,2 +1,2 @@ # -*- coding: utf-8 -*- - +from . import models diff --git a/fusion_theme_switcher/__manifest__.py b/fusion_theme_switcher/__manifest__.py index b4ed3011..0fc4f6b2 100644 --- a/fusion_theme_switcher/__manifest__.py +++ b/fusion_theme_switcher/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Fusion Theme Switcher", - "version": "19.0.1.0.1", + "version": "19.0.1.1.0", "category": "Productivity", "summary": "Backend header toggle for Odoo Enterprise light and dark mode.", "description": """ diff --git a/fusion_theme_switcher/models/__init__.py b/fusion_theme_switcher/models/__init__.py new file mode 100644 index 00000000..82fcc4bf --- /dev/null +++ b/fusion_theme_switcher/models/__init__.py @@ -0,0 +1 @@ +from . import res_users_settings diff --git a/fusion_theme_switcher/models/res_users_settings.py b/fusion_theme_switcher/models/res_users_settings.py new file mode 100644 index 00000000..e98cb9e7 --- /dev/null +++ b/fusion_theme_switcher/models/res_users_settings.py @@ -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)