Browse Source

publish muk_web_theme - 12.0

pull/48/head
MuK IT GmbH 6 years ago
parent
commit
02f726272d
  1. 2
      muk_web_theme/__manifest__.py
  2. 38
      muk_web_theme/models/res_config_settings.py

2
muk_web_theme/__manifest__.py

@ -19,7 +19,7 @@
{ {
"name": "MuK Backend Theme", "name": "MuK Backend Theme",
"summary": "Odoo 12.0 community backend theme", "summary": "Odoo 12.0 community backend theme",
"version": "12.0.1.1.14",
"version": "12.0.1.1.15",
"category": "Themes/Backend", "category": "Themes/Backend",
"license": "AGPL-3", "license": "AGPL-3",
"author": "MuK IT", "author": "MuK IT",

38
muk_web_theme/models/res_config_settings.py

@ -26,14 +26,6 @@ from odoo import api, fields, models
XML_ID = "muk_web_theme._assets_primary_variables" XML_ID = "muk_web_theme._assets_primary_variables"
SCSS_URL = "/muk_web_theme/static/src/scss/colors.scss" SCSS_URL = "/muk_web_theme/static/src/scss/colors.scss"
TEMPLATE = """
$o-brand-odoo: {0};
$o-brand-primary: {1};
$mk-brand-gradient-start: lighten($o-brand-odoo, 10%);
$mk-brand-gradient-end: lighten($o-brand-odoo, 20%);
"""
class ResConfigSettings(models.TransientModel): class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings' _inherit = 'res.config.settings'
@ -52,31 +44,23 @@ class ResConfigSettings(models.TransientModel):
@api.multi @api.multi
def set_values(self): def set_values(self):
res = super(ResConfigSettings, self).set_values() res = super(ResConfigSettings, self).set_values()
self._save_scss_values()
variables = [
{'name': 'o-brand-odoo', 'value': self.theme_color_brand or "#243742"},
{'name': 'o-brand-primary', 'value': self.theme_color_primary or "#5D8DA8"},
]
self.env['muk_utils.scss_editor'].replace_values(
SCSS_URL, XML_ID, variables
)
return res return res
@api.model @api.model
def get_values(self): def get_values(self):
res = super(ResConfigSettings, self).get_values() res = super(ResConfigSettings, self).get_values()
res.update(self._get_scss_values())
return res
def _get_scss_values(self):
colors = self.env['muk_utils.scss_editor'].get_value(
colors = self.env['muk_utils.scss_editor'].get_values(
SCSS_URL, XML_ID, ['o-brand-odoo', 'o-brand-primary'] SCSS_URL, XML_ID, ['o-brand-odoo', 'o-brand-primary']
) )
return {
res.update({
'theme_color_brand': colors['o-brand-odoo'], 'theme_color_brand': colors['o-brand-odoo'],
'theme_color_primary': colors['o-brand-primary'], 'theme_color_primary': colors['o-brand-primary'],
}
def _build_custom_scss_template(self):
return TEMPLATE.format(
self.theme_color_brand or "#243742",
self.theme_color_primary or "#5D8DA8"
)
def _save_scss_values(self):
self.env['muk_utils.scss_editor'].replace_content(
SCSS_URL, XML_ID, self._build_custom_scss_template()
)
})
return res
Loading…
Cancel
Save