Browse Source

publish muk_web_theme - 13.0

13.0
MuK IT GmbH 4 years ago
parent
commit
3ff02ae457
  1. 2
      muk_web_theme/__manifest__.py
  2. 310
      muk_web_theme/models/res_config_settings.py
  3. 354
      muk_web_theme/views/res_config_settings_view.xml

2
muk_web_theme/__manifest__.py

@ -22,7 +22,7 @@
{
"name": "MuK Backend Theme",
"summary": "Odoo Community Backend Theme",
"version": "13.0.1.0.1",
"version": "13.0.1.0.2",
"category": "Themes/Backend",
"license": "LGPL-3",
"author": "MuK IT",

310
muk_web_theme/models/res_config_settings.py

@ -1,154 +1,158 @@
###################################################################################
#
# Copyright (c) 2017-2019 MuK IT GmbH.
#
# This file is part of MuK Backend Theme
# (see https://mukit.at).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###################################################################################
import re
import uuid
import base64
from odoo import api, fields, models
XML_ID = "muk_web_theme._assets_primary_variables"
SCSS_URL = "/muk_web_theme/static/src/scss/colors.scss"
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
#----------------------------------------------------------
# Database
#----------------------------------------------------------
module_muk_web_theme_mail = fields.Boolean(
string="Theme Mail",
help="Optimizes the mail chatter for the theme.")
module_muk_web_theme_branding = fields.Boolean(
string="Theme Branding",
help="Customize the theme according to your needs.")
module_muk_web_theme_website = fields.Boolean(
string="Theme Website",
help="Add theme styled website navigation.")
module_muk_web_theme_mobile = fields.Boolean(
string="Theme Mobile",
help="Allow Odoo to be used as a PWA app.")
theme_background_image = fields.Binary(
related="company_id.background_image",
readonly=False)
theme_background_blend_mode = fields.Selection(
related="company_id.background_blend_mode",
readonly=False)
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_required = fields.Char(
string="Theme Required Color")
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
#----------------------------------------------------------
def set_values(self):
res = super(ResConfigSettings, self).set_values()
param = self.env['ir.config_parameter'].with_user(self.env.ref('base.user_admin'))
variables = [
'o-brand-odoo',
'o-brand-primary',
'mk-required-color',
'mk-apps-color',
'mk-appbar-color',
'mk-appbar-background',
]
colors = self.env['muk_utils.scss_editor'].get_values(
SCSS_URL, XML_ID, variables
)
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_required != colors['mk-required-color'])
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-required-color', 'value': self.theme_color_required or "#d1dfe6"},
{'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
)
param.set_param('muk_web_theme.background_blend_mode', self.theme_background_blend_mode)
return res
@api.model
def get_values(self):
res = super(ResConfigSettings, self).get_values()
params = self.env['ir.config_parameter'].with_user(self.env.ref('base.user_admin'))
variables = [
'o-brand-odoo',
'o-brand-primary',
'mk-required-color',
'mk-apps-color',
'mk-appbar-color',
'mk-appbar-background',
]
colors = self.env['muk_utils.scss_editor'].get_values(
SCSS_URL, XML_ID, variables
)
res.update({
'theme_color_brand': colors['o-brand-odoo'],
'theme_color_primary': colors['o-brand-primary'],
'theme_color_required': colors['mk-required-color'],
'theme_color_menu': colors['mk-apps-color'],
'theme_color_appbar_color': colors['mk-appbar-color'],
'theme_color_appbar_background': colors['mk-appbar-background'],
'theme_background_blend_mode': params.get_param('muk_web_theme.background_blend_mode', 'normal'),
})
###################################################################################
#
# Copyright (c) 2017-2019 MuK IT GmbH.
#
# This file is part of MuK Backend Theme
# (see https://mukit.at).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###################################################################################
import re
import uuid
import base64
from odoo import api, fields, models
XML_ID = "muk_web_theme._assets_primary_variables"
SCSS_URL = "/muk_web_theme/static/src/scss/colors.scss"
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
#----------------------------------------------------------
# Database
#----------------------------------------------------------
module_muk_web_theme_mail = fields.Boolean(
string="Theme Mail",
help="Optimizes the mail chatter for the theme.")
module_muk_web_theme_branding = fields.Boolean(
string="Theme Branding",
help="Customize the theme according to your needs.")
module_muk_web_theme_website = fields.Boolean(
string="Theme Website",
help="Add theme styled website navigation.")
module_muk_web_theme_mobile = fields.Boolean(
string="Theme Mobile",
help="Allow Odoo to be used as a PWA app.")
theme_favicon = fields.Binary(
related="company_id.favicon",
readonly=False)
theme_background_image = fields.Binary(
related="company_id.background_image",
readonly=False)
theme_background_blend_mode = fields.Selection(
related="company_id.background_blend_mode",
readonly=False)
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_required = fields.Char(
string="Theme Required Color")
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
#----------------------------------------------------------
def set_values(self):
res = super(ResConfigSettings, self).set_values()
param = self.env['ir.config_parameter'].with_user(self.env.ref('base.user_admin'))
variables = [
'o-brand-odoo',
'o-brand-primary',
'mk-required-color',
'mk-apps-color',
'mk-appbar-color',
'mk-appbar-background',
]
colors = self.env['muk_utils.scss_editor'].get_values(
SCSS_URL, XML_ID, variables
)
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_required != colors['mk-required-color'])
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-required-color', 'value': self.theme_color_required or "#d1dfe6"},
{'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
)
param.set_param('muk_web_theme.background_blend_mode', self.theme_background_blend_mode)
return res
@api.model
def get_values(self):
res = super(ResConfigSettings, self).get_values()
params = self.env['ir.config_parameter'].with_user(self.env.ref('base.user_admin'))
variables = [
'o-brand-odoo',
'o-brand-primary',
'mk-required-color',
'mk-apps-color',
'mk-appbar-color',
'mk-appbar-background',
]
colors = self.env['muk_utils.scss_editor'].get_values(
SCSS_URL, XML_ID, variables
)
res.update({
'theme_color_brand': colors['o-brand-odoo'],
'theme_color_primary': colors['o-brand-primary'],
'theme_color_required': colors['mk-required-color'],
'theme_color_menu': colors['mk-apps-color'],
'theme_color_appbar_color': colors['mk-appbar-color'],
'theme_color_appbar_background': colors['mk-appbar-background'],
'theme_background_blend_mode': params.get_param('muk_web_theme.background_blend_mode', 'normal'),
})
return res

354
muk_web_theme/views/res_config_settings_view.xml

@ -1,169 +1,185 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2017-2019 MuK IT GmbH.
This file is part of MuK Backend Theme
(see https://mukit.at).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="base_setup.res_config_settings_view_form"/>
<field name="arch" type="xml">
<div id="business_documents" position="after">
<h2 id="web_theme_title">Backend Theme</h2>
<div class="row mt16 o_settings_container" name="web_theme">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
</div>
<div class="o_setting_right_pane">
<span class="o_form_label">Default Preferences</span>
<div class="text-muted">
Set the default theme preferences
</div>
<div class="content-group">
<div class="mt16 row">
<label for="theme_default_sidebar_preference" string="Sidebar" class="col-3 o_light_label"/>
<field name="theme_default_sidebar_preference" class="col-5"/>
<div class="w-100"></div>
<label for="theme_default_chatter_preference" string="Chatter" class="col-3 o_light_label"/>
<field name="theme_default_chatter_preference" class="col-5"/>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
</div>
<div class="o_setting_right_pane">
<span class="o_form_label">Theme Colors</span>
<div class="text-muted">
Set the main theme colors
</div>
<div class="content-group">
<div class="mt16 row">
<label for="theme_color_brand" string="Brand" class="col-3 o_light_label"/>
<field name="theme_color_brand" widget="color" class="oe_inline"/>
<div class="w-100"></div>
<label for="theme_color_primary" string="Primary" class="col-3 o_light_label"/>
<field name="theme_color_primary" widget="color" class="oe_inline"/>
<div class="w-100"></div>
<label for="theme_color_required" string="Required" class="col-3 o_light_label"/>
<field name="theme_color_required" widget="color" class="oe_inline"/>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
</div>
<div class="o_setting_right_pane">
<span class="o_form_label">Background Image</span>
<span class="fa fa-lg fa-building-o" title="Values set here are company-specific." aria-label="Values set here are company-specific." groups="base.group_multi_company" role="img"/>
<div class="text-muted">
Set the background image for the apps menu
</div>
<div class="content-group">
<div class="mt16 row">
<field name="theme_background_image" widget="image" class="ml-4" required="1"/>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
</div>
<div class="o_setting_right_pane">
<span class="o_form_label">Menu Colors</span>
<div class="text-muted">
Set the main menu colors
</div>
<div class="content-group">
<div class="mt16 row">
<label for="theme_color_appbar_color" string="Menu Color" class="col-3 o_light_label"/>
<field name="theme_color_appbar_color" widget="color" class="oe_inline"/>
<div class="w-100"></div>
<label for="theme_color_appbar_background" string="Background" class="col-3 o_light_label"/>
<field name="theme_color_appbar_background" widget="color" class="oe_inline"/>
<div class="w-100"></div>
<label for="theme_color_menu" string="Apps Color" class="col-3 o_light_label"/>
<field name="theme_color_menu" widget="color" class="oe_inline"/>
<div class="w-100"></div>
<label for="theme_background_blend_mode" string="Apps Blend" class="col-3 o_light_label"/>
<field name="theme_background_blend_mode" class="col-5"/>
</div>
</div>
</div>
</div>
</div>
<h2 id="web_theme_extension_title">Backend Theme Extensions</h2>
<div class="row mt16 o_settings_container" name="web_theme_extension">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="module_muk_web_theme_mail"/>
</div>
<div class="o_setting_right_pane">
<label for="module_muk_web_theme_mail"/>
<div class="text-muted">
Optimizes the mail chatter for the theme
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="module_muk_web_theme_branding"/>
</div>
<div class="o_setting_right_pane">
<label for="module_muk_web_theme_branding"/>
<div class="text-muted">
Customize the theme according to your needs
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="module_muk_web_theme_website"/>
</div>
<div class="o_setting_right_pane">
<label for="module_muk_web_theme_website"/>
<div class="text-muted">
Add theme styled website navigation
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="module_muk_web_theme_mobile"/>
</div>
<div class="o_setting_right_pane">
<label for="module_muk_web_theme_mobile"/>
<div class="text-muted">
Allow Odoo to be used as a PWA app
</div>
</div>
</div>
</div>
</div>
</field>
</record>
</odoo>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2017-2019 MuK IT GmbH.
This file is part of MuK Backend Theme
(see https://mukit.at).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="base_setup.res_config_settings_view_form"/>
<field name="arch" type="xml">
<div id="business_documents" position="after">
<h2 id="web_theme_title">Backend Theme</h2>
<div class="row mt16 o_settings_container" name="web_theme">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
</div>
<div class="o_setting_right_pane">
<span class="o_form_label">Default Preferences</span>
<div class="text-muted">
Set the default theme preferences
</div>
<div class="content-group">
<div class="mt16 row">
<label for="theme_default_sidebar_preference" string="Sidebar" class="col-3 o_light_label"/>
<field name="theme_default_sidebar_preference" class="col-5"/>
<div class="w-100"></div>
<label for="theme_default_chatter_preference" string="Chatter" class="col-3 o_light_label"/>
<field name="theme_default_chatter_preference" class="col-5"/>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
</div>
<div class="o_setting_right_pane">
<span class="o_form_label">Favicon</span>
<span class="fa fa-lg fa-building-o" title="Values set here are company-specific." aria-label="Values set here are company-specific." groups="base.group_multi_company" role="img"/>
<div class="text-muted">
Set the favicon for the system
</div>
<div class="content-group">
<div class="mt16 row">
<field name="theme_favicon_backend" widget="image" class="ml-4 oe_avatar" required="1"/>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
</div>
<div class="o_setting_right_pane">
<span class="o_form_label">Theme Colors</span>
<div class="text-muted">
Set the main theme colors
</div>
<div class="content-group">
<div class="mt16 row">
<label for="theme_color_brand" string="Brand" class="col-3 o_light_label"/>
<field name="theme_color_brand" widget="color" class="oe_inline"/>
<div class="w-100"></div>
<label for="theme_color_primary" string="Primary" class="col-3 o_light_label"/>
<field name="theme_color_primary" widget="color" class="oe_inline"/>
<div class="w-100"></div>
<label for="theme_color_required" string="Required" class="col-3 o_light_label"/>
<field name="theme_color_required" widget="color" class="oe_inline"/>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
</div>
<div class="o_setting_right_pane">
<span class="o_form_label">Menu Colors</span>
<div class="text-muted">
Set the main menu colors
</div>
<div class="content-group">
<div class="mt16 row">
<label for="theme_color_appbar_color" string="Menu Color" class="col-3 o_light_label"/>
<field name="theme_color_appbar_color" widget="color" class="oe_inline"/>
<div class="w-100"></div>
<label for="theme_color_appbar_background" string="Background" class="col-3 o_light_label"/>
<field name="theme_color_appbar_background" widget="color" class="oe_inline"/>
<div class="w-100"></div>
<label for="theme_color_menu" string="Apps Color" class="col-3 o_light_label"/>
<field name="theme_color_menu" widget="color" class="oe_inline"/>
<div class="w-100"></div>
<label for="theme_background_blend_mode" string="Apps Blend" class="col-3 o_light_label"/>
<field name="theme_background_blend_mode" class="col-5"/>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
</div>
<div class="o_setting_right_pane">
<span class="o_form_label">Background Image</span>
<span class="fa fa-lg fa-building-o" title="Values set here are company-specific." aria-label="Values set here are company-specific." groups="base.group_multi_company" role="img"/>
<div class="text-muted">
Set the background image for the apps menu
</div>
<div class="content-group">
<div class="mt16 row">
<field name="theme_background_image" widget="image" class="ml-4" required="1"/>
</div>
</div>
</div>
</div>
</div>
<h2 id="web_theme_extension_title">Backend Theme Extensions</h2>
<div class="row mt16 o_settings_container" name="web_theme_extension">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="module_muk_web_theme_mail"/>
</div>
<div class="o_setting_right_pane">
<label for="module_muk_web_theme_mail"/>
<div class="text-muted">
Optimizes the mail chatter for the theme
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="module_muk_web_theme_branding"/>
</div>
<div class="o_setting_right_pane">
<label for="module_muk_web_theme_branding"/>
<div class="text-muted">
Customize the theme according to your needs
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="module_muk_web_theme_website"/>
</div>
<div class="o_setting_right_pane">
<label for="module_muk_web_theme_website"/>
<div class="text-muted">
Add theme styled website navigation
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="module_muk_web_theme_mobile"/>
</div>
<div class="o_setting_right_pane">
<label for="module_muk_web_theme_mobile"/>
<div class="text-muted">
Allow Odoo to be used as a PWA app
</div>
</div>
</div>
</div>
</div>
</field>
</record>
</odoo>
Loading…
Cancel
Save