forked from Techsystech/web
[IMP] web_company_color: black, isort, prettier
parent
38f0903100
commit
56893f28d0
|
@ -3,20 +3,16 @@
|
||||||
#
|
#
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).#
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).#
|
||||||
{
|
{
|
||||||
'name': "Web Company Color",
|
"name": "Web Company Color",
|
||||||
'category': "web",
|
"category": "web",
|
||||||
'version': "12.0.1.1.0",
|
"version": "13.0.1.0.0",
|
||||||
"author": "Alexandre Díaz, "
|
"author": "Alexandre Díaz, " "Odoo Community Association (OCA)",
|
||||||
"Odoo Community Association (OCA)",
|
"website": "https://github.com/OCA/web",
|
||||||
'website': 'https://github.com/OCA/web',
|
"depends": ["web", "base_sparse_field", "web_widget_color"],
|
||||||
'depends': ['web', 'base_sparse_field', 'web_widget_color'],
|
"data": ["view/assets.xml", "view/res_company.xml"],
|
||||||
'data': [
|
"uninstall_hook": "uninstall_hook",
|
||||||
'view/assets.xml',
|
"post_init_hook": "post_init_hook",
|
||||||
'view/res_company.xml'
|
"license": "AGPL-3",
|
||||||
],
|
"auto_install": False,
|
||||||
'uninstall_hook': 'uninstall_hook',
|
"installable": True,
|
||||||
'post_init_hook': 'post_init_hook',
|
|
||||||
'license': 'AGPL-3',
|
|
||||||
'auto_install': False,
|
|
||||||
'installable': True,
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
# Copyright 2019 Alexandre Díaz <dev@redneboa.es>
|
# Copyright 2019 Alexandre Díaz <dev@redneboa.es>
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
from odoo import api, SUPERUSER_ID
|
from odoo import SUPERUSER_ID, api
|
||||||
|
|
||||||
from .models.res_company import URL_BASE
|
from .models.res_company import URL_BASE
|
||||||
|
|
||||||
|
|
||||||
def uninstall_hook(cr, registry):
|
def uninstall_hook(cr, registry):
|
||||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||||
env["ir.attachment"].search([('url', 'like', '%s%%' % URL_BASE)]).unlink()
|
env["ir.attachment"].search([("url", "like", "%s%%" % URL_BASE)]).unlink()
|
||||||
|
|
||||||
|
|
||||||
def post_init_hook(cr, registry):
|
def post_init_hook(cr, registry):
|
||||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||||
env['res.company'].search([]).scss_create_or_update_attachment()
|
env["res.company"].search([]).scss_create_or_update_attachment()
|
||||||
|
|
|
@ -2,17 +2,18 @@
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
import base64
|
import base64
|
||||||
import time
|
import time
|
||||||
from colorsys import rgb_to_hls, hls_to_rgb
|
from colorsys import hls_to_rgb, rgb_to_hls
|
||||||
from odoo import models, fields, api
|
|
||||||
from ..utils import image_to_rgb, convert_to_image, n_rgb_to_hex
|
|
||||||
|
|
||||||
|
from odoo import api, fields, models
|
||||||
|
|
||||||
URL_BASE = '/web_company_color/static/src/scss/'
|
from ..utils import convert_to_image, image_to_rgb, n_rgb_to_hex
|
||||||
URL_SCSS_GEN_TEMPLATE = URL_BASE + 'custom_colors.%d.%s.gen.scss'
|
|
||||||
|
URL_BASE = "/web_company_color/static/src/scss/"
|
||||||
|
URL_SCSS_GEN_TEMPLATE = URL_BASE + "custom_colors.%d.%s.gen.scss"
|
||||||
|
|
||||||
|
|
||||||
class ResCompany(models.Model):
|
class ResCompany(models.Model):
|
||||||
_inherit = 'res.company'
|
_inherit = "res.company"
|
||||||
|
|
||||||
SCSS_TEMPLATE = """
|
SCSS_TEMPLATE = """
|
||||||
.o_main_navbar {
|
.o_main_navbar {
|
||||||
|
@ -47,13 +48,12 @@ class ResCompany(models.Model):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
company_colors = fields.Serialized()
|
company_colors = fields.Serialized()
|
||||||
color_navbar_bg = fields.Char('Navbar Background Color',
|
color_navbar_bg = fields.Char("Navbar Background Color", sparse="company_colors")
|
||||||
sparse='company_colors')
|
|
||||||
color_navbar_bg_hover = fields.Char(
|
color_navbar_bg_hover = fields.Char(
|
||||||
'Navbar Background Color Hover', sparse='company_colors')
|
"Navbar Background Color Hover", sparse="company_colors"
|
||||||
color_navbar_text = fields.Char('Navbar Text Color',
|
)
|
||||||
sparse='company_colors')
|
color_navbar_text = fields.Char("Navbar Text Color", sparse="company_colors")
|
||||||
scss_modif_timestamp = fields.Char('SCSS Modif. Timestamp')
|
scss_modif_timestamp = fields.Char("SCSS Modif. Timestamp")
|
||||||
|
|
||||||
@api.model_create_multi
|
@api.model_create_multi
|
||||||
def create(self, vals_list):
|
def create(self, vals_list):
|
||||||
|
@ -64,22 +64,24 @@ class ResCompany(models.Model):
|
||||||
@api.multi
|
@api.multi
|
||||||
def unlink(self):
|
def unlink(self):
|
||||||
result = super().unlink()
|
result = super().unlink()
|
||||||
IrAttachmentObj = self.env['ir.attachment']
|
IrAttachmentObj = self.env["ir.attachment"]
|
||||||
for record in self:
|
for record in self:
|
||||||
IrAttachmentObj.sudo().search([
|
IrAttachmentObj.sudo().search(
|
||||||
('url', 'like', '%s%%' % record._scss_get_url_simplified()),
|
[("url", "like", "%s%%" % record._scss_get_url_simplified())]
|
||||||
]).sudo().unlink()
|
).sudo().unlink()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def write(self, values):
|
def write(self, values):
|
||||||
if not self.env.context.get('ignore_company_color', False):
|
if not self.env.context.get("ignore_company_color", False):
|
||||||
fields_to_check = ('color_navbar_bg',
|
fields_to_check = (
|
||||||
'color_navbar_bg_hover',
|
"color_navbar_bg",
|
||||||
'color_navbar_text')
|
"color_navbar_bg_hover",
|
||||||
if 'logo' in values:
|
"color_navbar_text",
|
||||||
if values['logo']:
|
)
|
||||||
_r, _g, _b = image_to_rgb(convert_to_image(values['logo']))
|
if "logo" in values:
|
||||||
|
if values["logo"]:
|
||||||
|
_r, _g, _b = image_to_rgb(convert_to_image(values["logo"]))
|
||||||
# Make color 10% darker
|
# Make color 10% darker
|
||||||
_h, _l, _s = rgb_to_hls(_r, _g, _b)
|
_h, _l, _s = rgb_to_hls(_r, _g, _b)
|
||||||
_l = max(0, _l - 0.1)
|
_l = max(0, _l - 0.1)
|
||||||
|
@ -87,11 +89,13 @@ class ResCompany(models.Model):
|
||||||
# Calc. optimal text color (b/w)
|
# Calc. optimal text color (b/w)
|
||||||
# Grayscale human vision perception (Rec. 709 values)
|
# Grayscale human vision perception (Rec. 709 values)
|
||||||
_a = 1 - (0.2126 * _r + 0.7152 * _g + 0.0722 * _b)
|
_a = 1 - (0.2126 * _r + 0.7152 * _g + 0.0722 * _b)
|
||||||
values.update({
|
values.update(
|
||||||
'color_navbar_bg': n_rgb_to_hex(_r, _g, _b),
|
{
|
||||||
'color_navbar_bg_hover': n_rgb_to_hex(_rd, _gd, _bd),
|
"color_navbar_bg": n_rgb_to_hex(_r, _g, _b),
|
||||||
'color_navbar_text': '#000' if _a < 0.5 else '#fff',
|
"color_navbar_bg_hover": n_rgb_to_hex(_rd, _gd, _bd),
|
||||||
})
|
"color_navbar_text": "#000" if _a < 0.5 else "#fff",
|
||||||
|
}
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
values.update(self.default_get(fields_to_check))
|
values.update(self.default_get(fields_to_check))
|
||||||
|
|
||||||
|
@ -110,14 +114,16 @@ class ResCompany(models.Model):
|
||||||
# This allow extend company_colors and only sanitize selected fields
|
# This allow extend company_colors and only sanitize selected fields
|
||||||
# or add custom values
|
# or add custom values
|
||||||
values = dict(self.company_colors or {})
|
values = dict(self.company_colors or {})
|
||||||
values.update({
|
values.update(
|
||||||
'color_navbar_bg': (values.get('color_navbar_bg')
|
{
|
||||||
or '$o-brand-odoo'),
|
"color_navbar_bg": (values.get("color_navbar_bg") or "$o-brand-odoo"),
|
||||||
'color_navbar_bg_hover': (
|
"color_navbar_bg_hover": (
|
||||||
values.get('color_navbar_bg_hover')
|
values.get("color_navbar_bg_hover")
|
||||||
or '$o-navbar-inverse-link-hover-bg'),
|
or "$o-navbar-inverse-link-hover-bg"
|
||||||
'color_navbar_text': (values.get('color_navbar_text') or '#FFF'),
|
),
|
||||||
})
|
"color_navbar_text": (values.get("color_navbar_text") or "#FFF"),
|
||||||
|
}
|
||||||
|
)
|
||||||
return values
|
return values
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
|
@ -132,42 +138,37 @@ class ResCompany(models.Model):
|
||||||
# /web_company_color/static/src/scss/custom_colors.<company_id>
|
# /web_company_color/static/src/scss/custom_colors.<company_id>
|
||||||
def _scss_get_url_simplified(self):
|
def _scss_get_url_simplified(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
NTEMPLATE = '.'.join(URL_SCSS_GEN_TEMPLATE.split('.')[:2])
|
NTEMPLATE = ".".join(URL_SCSS_GEN_TEMPLATE.split(".")[:2])
|
||||||
return NTEMPLATE % self.id
|
return NTEMPLATE % self.id
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def scss_get_url(self, timestamp=None):
|
def scss_get_url(self, timestamp=None):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
return URL_SCSS_GEN_TEMPLATE % (self.id,
|
return URL_SCSS_GEN_TEMPLATE % (self.id, timestamp or self.scss_modif_timestamp)
|
||||||
timestamp or self.scss_modif_timestamp)
|
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def scss_create_or_update_attachment(self):
|
def scss_create_or_update_attachment(self):
|
||||||
IrAttachmentObj = self.env['ir.attachment']
|
IrAttachmentObj = self.env["ir.attachment"]
|
||||||
# The time window is 1 second
|
# The time window is 1 second
|
||||||
# This mean that all modifications realized in that second will
|
# This mean that all modifications realized in that second will
|
||||||
# have the same timestamp
|
# have the same timestamp
|
||||||
modif_timestamp = str(int(time.time()))
|
modif_timestamp = str(int(time.time()))
|
||||||
for record in self:
|
for record in self:
|
||||||
datas = base64.b64encode(
|
datas = base64.b64encode(record._scss_generate_content().encode("utf-8"))
|
||||||
record._scss_generate_content().encode('utf-8'))
|
custom_attachment = IrAttachmentObj.sudo().search(
|
||||||
custom_attachment = IrAttachmentObj.sudo().search([
|
[("url", "like", "%s%%" % record._scss_get_url_simplified())]
|
||||||
('url', 'like', '%s%%' % record._scss_get_url_simplified())
|
)
|
||||||
])
|
|
||||||
custom_url = record.scss_get_url(timestamp=modif_timestamp)
|
custom_url = record.scss_get_url(timestamp=modif_timestamp)
|
||||||
values = {
|
values = {
|
||||||
'datas': datas,
|
"datas": datas,
|
||||||
'url': custom_url,
|
"url": custom_url,
|
||||||
'name': custom_url,
|
"name": custom_url,
|
||||||
'datas_fname': custom_url.split("/")[-1],
|
"datas_fname": custom_url.split("/")[-1],
|
||||||
}
|
}
|
||||||
if custom_attachment:
|
if custom_attachment:
|
||||||
custom_attachment.sudo().write(values)
|
custom_attachment.sudo().write(values)
|
||||||
else:
|
else:
|
||||||
values.update({
|
values.update({"type": "binary", "mimetype": "text/scss"})
|
||||||
'type': 'binary',
|
|
||||||
'mimetype': 'text/scss',
|
|
||||||
})
|
|
||||||
IrAttachmentObj.sudo().create(values)
|
IrAttachmentObj.sudo().create(values)
|
||||||
self.write({'scss_modif_timestamp': modif_timestamp})
|
self.write({"scss_modif_timestamp": modif_timestamp})
|
||||||
self.env['ir.qweb'].sudo().clear_caches()
|
self.env["ir.qweb"].sudo().clear_caches()
|
||||||
|
|
|
@ -1,59 +1,73 @@
|
||||||
# Copyright 2019 Alexandre Díaz <dev@redneboa.es>
|
# Copyright 2019 Alexandre Díaz <dev@redneboa.es>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
from odoo.tests import common
|
from odoo.tests import common
|
||||||
|
|
||||||
from ..models.res_company import URL_BASE
|
from ..models.res_company import URL_BASE
|
||||||
|
|
||||||
|
|
||||||
class TestResCompany(common.TransactionCase):
|
class TestResCompany(common.TransactionCase):
|
||||||
IMG_GREEN = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUl' \
|
IMG_GREEN = (
|
||||||
+ 'EQVR42mNk+M/wHwAEBgIApD5fRAAAAABJRU5ErkJggg=='
|
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUl"
|
||||||
|
+ "EQVR42mNk+M/wHwAEBgIApD5fRAAAAABJRU5ErkJggg=="
|
||||||
|
)
|
||||||
|
|
||||||
def test_scss_attachment(self):
|
def test_scss_attachment(self):
|
||||||
num_scss = self.env['ir.attachment'].search_count([
|
num_scss = self.env["ir.attachment"].search_count(
|
||||||
('url', 'ilike', '%s%%' % URL_BASE)
|
[("url", "ilike", "%s%%" % URL_BASE)]
|
||||||
])
|
)
|
||||||
num_companies = self.env['res.company'].search_count([])
|
num_companies = self.env["res.company"].search_count([])
|
||||||
self.assertEqual(num_scss, num_companies, "Invalid scss attachments")
|
self.assertEqual(num_scss, num_companies, "Invalid scss attachments")
|
||||||
|
|
||||||
def test_create_unlink_company(self):
|
def test_create_unlink_company(self):
|
||||||
company_id = self.env['res.company'].create({
|
company_id = self.env["res.company"].create({"name": "Company Test"})
|
||||||
'name': 'Company Test'
|
self.assertEqual(
|
||||||
})
|
company_id.color_navbar_bg, False, "Invalid Navbar Background Color"
|
||||||
self.assertEqual(company_id.color_navbar_bg, False,
|
)
|
||||||
"Invalid Navbar Background Color")
|
|
||||||
self.test_scss_attachment()
|
self.test_scss_attachment()
|
||||||
company_id.sudo().write({'logo': self.IMG_GREEN})
|
company_id.sudo().write({"logo": self.IMG_GREEN})
|
||||||
self.assertEqual(company_id.color_navbar_bg, '#00ff00',
|
self.assertEqual(
|
||||||
"Invalid Navbar Background Color")
|
company_id.color_navbar_bg, "#00ff00", "Invalid Navbar Background Color"
|
||||||
|
)
|
||||||
company_id.sudo().unlink()
|
company_id.sudo().unlink()
|
||||||
self.test_scss_attachment()
|
self.test_scss_attachment()
|
||||||
|
|
||||||
def test_change_logo(self):
|
def test_change_logo(self):
|
||||||
company_id = self.env['res.company'].search([], limit=1)
|
company_id = self.env["res.company"].search([], limit=1)
|
||||||
company_id.sudo().write({'logo': self.IMG_GREEN})
|
company_id.sudo().write({"logo": self.IMG_GREEN})
|
||||||
self.assertEqual(company_id.color_navbar_bg, '#00ff00',
|
self.assertEqual(
|
||||||
"Invalid Navbar Background Color")
|
company_id.color_navbar_bg, "#00ff00", "Invalid Navbar Background Color"
|
||||||
|
)
|
||||||
|
|
||||||
def test_scss_sanitized_values(self):
|
def test_scss_sanitized_values(self):
|
||||||
company_id = self.env['res.company'].search([], limit=1)
|
company_id = self.env["res.company"].search([], limit=1)
|
||||||
company_id.sudo().write({'color_navbar_bg': False})
|
company_id.sudo().write({"color_navbar_bg": False})
|
||||||
values = company_id.sudo()._scss_get_sanitized_values()
|
values = company_id.sudo()._scss_get_sanitized_values()
|
||||||
self.assertEqual(values['color_navbar_bg'], '$o-brand-odoo',
|
self.assertEqual(
|
||||||
"Invalid Navbar Background Color")
|
values["color_navbar_bg"],
|
||||||
company_id.sudo().write({'color_navbar_bg': '#DEAD00'})
|
"$o-brand-odoo",
|
||||||
|
"Invalid Navbar Background Color",
|
||||||
|
)
|
||||||
|
company_id.sudo().write({"color_navbar_bg": "#DEAD00"})
|
||||||
values = company_id.sudo()._scss_get_sanitized_values()
|
values = company_id.sudo()._scss_get_sanitized_values()
|
||||||
self.assertEqual(values['color_navbar_bg'], '#DEAD00',
|
self.assertEqual(
|
||||||
"Invalid Navbar Background Color")
|
values["color_navbar_bg"], "#DEAD00", "Invalid Navbar Background Color"
|
||||||
|
)
|
||||||
|
|
||||||
def test_change_color(self):
|
def test_change_color(self):
|
||||||
company_id = self.env['res.company'].search([], limit=1)
|
company_id = self.env["res.company"].search([], limit=1)
|
||||||
company_id.sudo().write({'color_navbar_bg': '#DEAD00'})
|
company_id.sudo().write({"color_navbar_bg": "#DEAD00"})
|
||||||
self.assertEqual(company_id.color_navbar_bg, '#DEAD00',
|
self.assertEqual(
|
||||||
"Invalid Navbar Background Color")
|
company_id.color_navbar_bg, "#DEAD00", "Invalid Navbar Background Color"
|
||||||
self.assertEqual(company_id.company_colors['color_navbar_bg'],
|
)
|
||||||
'#DEAD00', "Invalid Navbar Background Color")
|
self.assertEqual(
|
||||||
company_id.sudo().write({'color_navbar_bg': False})
|
company_id.company_colors["color_navbar_bg"],
|
||||||
self.assertFalse(company_id.color_navbar_bg,
|
"#DEAD00",
|
||||||
"Invalid Navbar Background Color")
|
"Invalid Navbar Background Color",
|
||||||
self.assertNotIn('color_navbar_bg', company_id.company_colors,
|
)
|
||||||
"Invalid Navbar Background Color")
|
company_id.sudo().write({"color_navbar_bg": False})
|
||||||
|
self.assertFalse(company_id.color_navbar_bg, "Invalid Navbar Background Color")
|
||||||
|
self.assertNotIn(
|
||||||
|
"color_navbar_bg",
|
||||||
|
company_id.company_colors,
|
||||||
|
"Invalid Navbar Background Color",
|
||||||
|
)
|
||||||
|
|
|
@ -2,12 +2,13 @@
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
import base64
|
import base64
|
||||||
import math
|
import math
|
||||||
from PIL import Image
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
|
||||||
def n_rgb_to_hex(_r, _g, _b):
|
def n_rgb_to_hex(_r, _g, _b):
|
||||||
return '#%02x%02x%02x' % (int(255*_r), int(255*_g), int(255*_b))
|
return "#{:02x}{:02x}{:02x}".format(int(255 * _r), int(255 * _g), int(255 * _b))
|
||||||
|
|
||||||
|
|
||||||
def convert_to_image(field_binary):
|
def convert_to_image(field_binary):
|
||||||
|
@ -16,22 +17,20 @@ def convert_to_image(field_binary):
|
||||||
|
|
||||||
def image_to_rgb(img):
|
def image_to_rgb(img):
|
||||||
def normalize_vec3(vec3):
|
def normalize_vec3(vec3):
|
||||||
_l = 1.0 / math.sqrt(vec3[0]*vec3[0]
|
_l = 1.0 / math.sqrt(vec3[0] * vec3[0] + vec3[1] * vec3[1] + vec3[2] * vec3[2])
|
||||||
+ vec3[1]*vec3[1]
|
return (vec3[0] * _l, vec3[1] * _l, vec3[2] * _l)
|
||||||
+ vec3[2]*vec3[2])
|
|
||||||
return (vec3[0]*_l, vec3[1]*_l, vec3[2]*_l)
|
|
||||||
|
|
||||||
# Force Alpha Channel
|
# Force Alpha Channel
|
||||||
if img.mode != 'RGBA':
|
if img.mode != "RGBA":
|
||||||
img = img.convert('RGBA')
|
img = img.convert("RGBA")
|
||||||
width, height = img.size
|
width, height = img.size
|
||||||
# Reduce pixels
|
# Reduce pixels
|
||||||
width, height = (max(1, int(width/4)), max(1, int(height/4)))
|
width, height = (max(1, int(width / 4)), max(1, int(height / 4)))
|
||||||
img = img.resize((width, height))
|
img = img.resize((width, height))
|
||||||
rgb_sum = [0, 0, 0]
|
rgb_sum = [0, 0, 0]
|
||||||
# Mix. image colors using addition method
|
# Mix. image colors using addition method
|
||||||
RGBA_WHITE = (255, 255, 255, 255)
|
RGBA_WHITE = (255, 255, 255, 255)
|
||||||
for i in range(0, height*width):
|
for i in range(0, height * width):
|
||||||
rgba = img.getpixel((i % width, i / width))
|
rgba = img.getpixel((i % width, i / width))
|
||||||
if rgba[3] > 128 and rgba != RGBA_WHITE:
|
if rgba[3] > 128 and rgba != RGBA_WHITE:
|
||||||
rgb_sum[0] += rgba[0]
|
rgb_sum[0] += rgba[0]
|
||||||
|
|
|
@ -1,17 +1,25 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Copyright 2019 Alexandre Díaz
|
Copyright 2019 Alexandre Díaz
|
||||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<odoo>
|
<odoo>
|
||||||
<template id="assets_backend" name="web_company_color assets"
|
<template
|
||||||
inherit_id="web.assets_backend">
|
id="assets_backend"
|
||||||
|
name="web_company_color assets"
|
||||||
|
inherit_id="web.assets_backend"
|
||||||
|
>
|
||||||
<xpath expr=".">
|
<xpath expr=".">
|
||||||
<t t-set="company_id" t-value="request.env.user and request.env.user.company_id" />
|
<t
|
||||||
<link t-if="company_id" rel="stylesheet" type="text/scss"
|
t-set="company_id"
|
||||||
t-att-href="company_id.scss_get_url()" />
|
t-value="request.env.user and request.env.user.company_id"
|
||||||
|
/>
|
||||||
|
<link
|
||||||
|
t-if="company_id"
|
||||||
|
rel="stylesheet"
|
||||||
|
type="text/scss"
|
||||||
|
t-att-href="company_id.scss_get_url()"
|
||||||
|
/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0" ?>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Copyright 2019
|
Copyright 2019
|
||||||
@author Alexandre Díaz <dev@redneboa.es>
|
@author Alexandre Díaz <dev@redneboa.es>
|
||||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
<record id="view_company_form" model="ir.ui.view">
|
<record id="view_company_form" model="ir.ui.view">
|
||||||
<field name="model">res.company</field>
|
<field name="model">res.company</field>
|
||||||
<field name="inherit_id" ref="base.view_company_form" />
|
<field name="inherit_id" ref="base.view_company_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<notebook position="inside">
|
<notebook position="inside">
|
||||||
<page string="Company Styles" name="company_styles"
|
<page
|
||||||
groups="base.group_system">
|
string="Company Styles"
|
||||||
|
name="company_styles"
|
||||||
|
groups="base.group_system"
|
||||||
|
>
|
||||||
<group string="Navbar Colors" name="navbar_colors">
|
<group string="Navbar Colors" name="navbar_colors">
|
||||||
<field name="color_navbar_bg" widget="color" />
|
<field name="color_navbar_bg" widget="color" />
|
||||||
<field name="color_navbar_bg_hover" widget="color" />
|
<field name="color_navbar_bg_hover" widget="color" />
|
||||||
|
@ -29,5 +29,4 @@
|
||||||
</notebook>
|
</notebook>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
Loading…
Reference in New Issue