diff --git a/muk_web_theme/__manifest__.py b/muk_web_theme/__manifest__.py index a6b6cea..00d64d0 100644 --- a/muk_web_theme/__manifest__.py +++ b/muk_web_theme/__manifest__.py @@ -19,7 +19,7 @@ { "name": "MuK Backend Theme", "summary": "Odoo Community Backend Theme", - "version": "12.0.1.2.15", + "version": "12.0.1.4.0", "category": "Themes/Backend", "license": "AGPL-3", "author": "MuK IT", diff --git a/muk_web_theme/doc/changelog.rst b/muk_web_theme/doc/changelog.rst index 94350eb..97d0e8d 100644 --- a/muk_web_theme/doc/changelog.rst +++ b/muk_web_theme/doc/changelog.rst @@ -1,3 +1,14 @@ +`1.3.0` +------- + +- Default Preferences + + +`1.2.0` +------- + +- Added Menu Color Options + `1.2.0` ------- diff --git a/muk_web_theme/models/__init__.py b/muk_web_theme/models/__init__.py index 29c0a2c..c1d4d04 100644 --- a/muk_web_theme/models/__init__.py +++ b/muk_web_theme/models/__init__.py @@ -17,6 +17,6 @@ # ################################################################################### -from . import res_users from . import res_company +from . import res_users from . import res_config_settings diff --git a/muk_web_theme/models/res_company.py b/muk_web_theme/models/res_company.py index 347bc7c..1722ca7 100644 --- a/muk_web_theme/models/res_company.py +++ b/muk_web_theme/models/res_company.py @@ -23,6 +23,27 @@ class ResCompany(models.Model): _inherit = 'res.company' + #---------------------------------------------------------- + # Database + #---------------------------------------------------------- + background_image = fields.Binary( string="Apps Menu Background Image", - attachment=True) \ No newline at end of file + attachment=True) + + default_sidebar_preference = fields.Selection( + selection=[ + ('invisible', 'Invisible'), + ('small', 'Small'), + ('large', 'Large') + ], + string="Sidebar Type", + default='small') + + default_chatter_preference = fields.Selection( + selection=[ + ('normal', 'Normal'), + ('sided', 'Sided'), + ], + string="Chatter Position", + default='sided') \ No newline at end of file diff --git a/muk_web_theme/models/res_config_settings.py b/muk_web_theme/models/res_config_settings.py index f84e58c..7bc420a 100644 --- a/muk_web_theme/models/res_config_settings.py +++ b/muk_web_theme/models/res_config_settings.py @@ -30,10 +30,22 @@ 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") @@ -41,28 +53,45 @@ class ResConfigSettings(models.TransientModel): 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 \ No newline at end of file diff --git a/muk_web_theme/models/res_users.py b/muk_web_theme/models/res_users.py index 50d334f..0f3aa25 100644 --- a/muk_web_theme/models/res_users.py +++ b/muk_web_theme/models/res_users.py @@ -17,30 +17,46 @@ # ################################################################################### -from odoo import models, fields +from odoo import models, fields, api class ResUsers(models.Model): _inherit = 'res.users' + #---------------------------------------------------------- + # Defaults + #---------------------------------------------------------- + + @api.model + def _default_sidebar_type(self): + return self.env.user.company_id.default_sidebar_preference or 'small' + + @api.model + def _default_chatter_position(self): + return self.env.user.company_id.default_chatter_preference or 'sided' + + #---------------------------------------------------------- + # Database + #---------------------------------------------------------- + sidebar_type = fields.Selection( selection=[ ('invisible', 'Invisible'), ('small', 'Small'), ('large', 'Large') ], + required=True, string="Sidebar Type", - default='small', - required=True) + default=lambda self: self._default_sidebar_type()) chatter_position = fields.Selection( selection=[ ('normal', 'Normal'), ('sided', 'Sided'), ], + required=True, string="Chatter Position", - default='sided', - required=True) + default=lambda self: self._default_chatter_position()) def __init__(self, pool, cr): init_res = super(ResUsers, self).__init__(pool, cr) diff --git a/muk_web_theme/static/src/scss/apps.scss b/muk_web_theme/static/src/scss/apps.scss index 73700d4..aafeafd 100644 --- a/muk_web_theme/static/src/scss/apps.scss +++ b/muk_web_theme/static/src/scss/apps.scss @@ -67,7 +67,7 @@ width: 100%; } .o-app-name { - color: $gray-100; + color: $mk-apps-color; } .form-row { width: 100%; @@ -99,7 +99,7 @@ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; - color: $gray-100; + color: $mk-apps-color; &:hover, &:active, &.active { background-color: rgba(255, 255, 255, 0.05); } diff --git a/muk_web_theme/static/src/scss/appsbar.scss b/muk_web_theme/static/src/scss/appsbar.scss index f840c6f..4678f90 100644 --- a/muk_web_theme/static/src/scss/appsbar.scss +++ b/muk_web_theme/static/src/scss/appsbar.scss @@ -41,12 +41,12 @@ display: block; cursor: pointer; font-size: 13px; + font-weight: 300; + overflow: hidden; padding: 8px 11px; position: relative; text-decoration: none; - font-weight: 300; - color: gray('300'); - overflow: hidden; + color: $mk-appbar-color; text-overflow: ellipsis; .mk_apps_sidebar_icon { width: 22px; diff --git a/muk_web_theme/static/src/scss/colors.scss b/muk_web_theme/static/src/scss/colors.scss index f05c47f..94b09d6 100644 --- a/muk_web_theme/static/src/scss/colors.scss +++ b/muk_web_theme/static/src/scss/colors.scss @@ -24,6 +24,9 @@ $o-brand-odoo: #243742; $o-brand-primary: #5D8DA8; +$mk-apps-color: #f8f9fa; + +$mk-appbar-color: #dee2e6; $mk-appbar-background: #000000; $mk-brand-gradient-start: lighten($o-brand-odoo, 10%); diff --git a/muk_web_theme/views/res_config_settings_view.xml b/muk_web_theme/views/res_config_settings_view.xml index ce25fd4..273a8f9 100644 --- a/muk_web_theme/views/res_config_settings_view.xml +++ b/muk_web_theme/views/res_config_settings_view.xml @@ -27,6 +27,44 @@

Backend Theme

+
+
+
+
+ Default Preferences +
+ Set the default theme preferences +
+
+
+
+
+
+
+
+
+
+
+ Theme Colors +
+ Set the main theme colors +
+
+
+
+
+
+
@@ -47,20 +85,20 @@
- Theme Colors + Menu Colors
- Set the main theme colors + Set the main menu colors
-