@ -30,39 +30,68 @@ class ResConfigSettings(models.TransientModel):
_inherit = ' res.config.settings '
#----------------------------------------------------------
# Database
#----------------------------------------------------------
theme_background_image = fields . Binary (
related = " company_id.background_image " ,
readonly = False ,
required = True )
theme_default_sidebar_preference = fields . Selection (
related = " company_id.default_sidebar_preference " ,
readonly = False )
theme_default_chatter_preference = fields . Selection (
related = " company_id.default_chatter_preference " ,
readonly = False )
theme_color_brand = fields . Char (
string = " Theme Brand Color " )
theme_color_primary = fields . Char (
string = " Theme Primary Color " )
theme_color_appbar = fields . Char (
theme_color_menu = fields . Char (
string = " Theme Menu Color " )
theme_color_appbar_color = fields . Char (
string = " Theme AppBar Color " )
theme_color_appbar_background = fields . Char (
string = " Theme AppBar Background " )
#----------------------------------------------------------
# Functions
#----------------------------------------------------------
@api.multi
def set_values ( self ) :
res = super ( ResConfigSettings , self ) . set_values ( )
variables = [
' o-brand-odoo ' ,
' o-brand-primary ' ,
' mk-appbar-background '
' mk-apps-color ' ,
' mk-appbar-color ' ,
' mk-appbar-background ' ,
]
colors = self . env [ ' muk_utils.scss_editor ' ] . get_values (
SCSS_URL , XML_ID , variables
)
brand_changed = self . theme_color_brand != colors [ ' o-brand-odoo ' ]
primary_changed = self . theme_color_primary != colors [ ' o-brand-primary ' ]
appbar_changed = self . theme_color_appbar != colors [ ' mk-appbar-background ' ]
if ( brand_changed or primary_changed or appbar_changed ) :
colors_changed = [ ]
colors_changed . append ( self . theme_color_brand != colors [ ' o-brand-odoo ' ] )
colors_changed . append ( self . theme_color_primary != colors [ ' o-brand-primary ' ] )
colors_changed . append ( self . theme_color_menu != colors [ ' mk-apps-color ' ] )
colors_changed . append ( self . theme_color_appbar_color != colors [ ' mk-appbar-color ' ] )
colors_changed . append ( self . theme_color_appbar_background != colors [ ' mk-appbar-background ' ] )
if ( any ( colors_changed ) ) :
variables = [
{ ' name ' : ' o-brand-odoo ' , ' value ' : self . theme_color_brand or " #243742 " } ,
{ ' name ' : ' o-brand-primary ' , ' value ' : self . theme_color_primary or " #5D8DA8 " } ,
{ ' name ' : ' mk-appbar-background ' , ' value ' : self . theme_color_appbar or " #000000 " } ,
{ ' name ' : ' mk-apps-color ' , ' value ' : self . theme_color_menu or " #f8f9fa " } ,
{ ' name ' : ' mk-appbar-color ' , ' value ' : self . theme_color_appbar_color or " #dee2e6 " } ,
{ ' name ' : ' mk-appbar-background ' , ' value ' : self . theme_color_appbar_background or " #000000 " } ,
]
self . env [ ' muk_utils.scss_editor ' ] . replace_values (
SCSS_URL , XML_ID , variables
@ -75,7 +104,9 @@ class ResConfigSettings(models.TransientModel):
variables = [
' o-brand-odoo ' ,
' o-brand-primary ' ,
' mk-appbar-background '
' mk-apps-color ' ,
' mk-appbar-color ' ,
' mk-appbar-background ' ,
]
colors = self . env [ ' muk_utils.scss_editor ' ] . get_values (
SCSS_URL , XML_ID , variables
@ -83,6 +114,8 @@ class ResConfigSettings(models.TransientModel):
res . update ( {
' theme_color_brand ' : colors [ ' o-brand-odoo ' ] ,
' theme_color_primary ' : colors [ ' o-brand-primary ' ] ,
' theme_color_appbar ' : colors [ ' mk-appbar-background ' ] ,
' theme_color_menu ' : colors [ ' mk-apps-color ' ] ,
' theme_color_appbar_color ' : colors [ ' mk-appbar-color ' ] ,
' theme_color_appbar_background ' : colors [ ' mk-appbar-background ' ] ,
} )
return res