This commit is contained in:
李鹏宇
2026-06-06 22:45:05 +08:00
parent 0e9a494f94
commit 5f6094b2dc
@@ -3,6 +3,26 @@
from odoo import models, fields
import base64
import logging
_logger = logging.getLogger(__name__)
def _scss_val(val, default='', quote=False):
"""将 Python 值转换为合法的 SCSS 值
- None → default
- bool True → True (SCSS 中可作标识符比较 @if $x == True)
- bool False → False
- str/other → 原样输出(quote=True 时加引号)
"""
if val is None:
return default
if isinstance(val, bool):
return 'True' if val else 'False'
if quote:
return "'%s'" % val
return val
class res_company(models.Model):
@@ -358,78 +378,80 @@ $scrollbar_style:%s;
$backend_all_icon_style:%s;
$is_navbar_style:%s;
""" % (
rec.primary_color,
rec.primary_color,
rec.kanban_box_style,
_scss_val(rec.primary_color, '#111c43'),
_scss_val(rec.primary_color, '#111c43'),
_scss_val(rec.kanban_box_style, 'style_1'),
_scss_val(rec.secondary_color, '#FFFFFF'),
rec.secondary_color,
rec.header_background_color,
rec.header_font_color,
_scss_val(rec.header_background_color, '#ebedf6'),
_scss_val(rec.header_font_color, '#111c43'),
_scss_val(rec.body_background_type, 'bg_color'),
_scss_val(rec.header_background_type, 'header_color'),
_scss_val(rec.body_background_color, '#ebedf6'),
_scss_val(rec.body_font_family, 'Poppins', quote=True),
rec.body_background_type,
rec.header_background_type,
rec.body_background_color,
rec.body_font_family,
_scss_val(rec.button_style, 'style_1'),
rec.button_style,
_scss_val(rec.sidebar_background_style, 'color'),
_scss_val(rec.sidebar_background_color, '#111c43'),
_scss_val(rec.sidebar_font_color, '#e2e8f0'),
_scss_val(rec.sidebar_is_show_nav_bar),
_scss_val(rec.sidebar_collapse_style, 'collapsed'),
rec.sidebar_background_style,
rec.sidebar_background_color,
rec.sidebar_font_color,
rec.sidebar_is_show_nav_bar,
rec.sidebar_collapse_style,
rec.separator_style,
rec.separator_color,
rec.icon_style,
rec.dual_tone_icon_color_1,
rec.dual_tone_icon_color_2,
rec.primary_color,
rec.primary_color,
rec.secondary_color,
_scss_val(rec.separator_style, 'style_7'),
_scss_val(rec.separator_color, '#111c43'),
_scss_val(rec.icon_style, 'light_icon'),
_scss_val(rec.dual_tone_icon_color_1, '#A3A5B7'),
_scss_val(rec.dual_tone_icon_color_2, '#2C3782'),
_scss_val(rec.primary_color, '#111c43'),
_scss_val(rec.primary_color, '#111c43'),
_scss_val(rec.secondary_color, '#FFFFFF'),
rec.body_google_font_family,
rec.is_used_google_font,
_scss_val(rec.body_google_font_family, 'Inter', quote=True),
_scss_val(rec.is_used_google_font),
rec.predefined_list_view_boolean,
rec.predefined_list_view_style,
rec.list_view_border,
rec.list_view_is_hover_row,
rec.list_view_hover_bg_color,
rec.list_view_even_row_color,
rec.list_view_odd_row_color,
_scss_val(rec.predefined_list_view_boolean),
_scss_val(rec.predefined_list_view_style, 'style_1'),
_scss_val(rec.list_view_border, 'without_border'),
_scss_val(rec.list_view_is_hover_row),
_scss_val(rec.list_view_hover_bg_color, '#111c43'),
_scss_val(rec.list_view_even_row_color, '#FFFFFF'),
_scss_val(rec.list_view_odd_row_color, '#FFFFFF'),
rec.login_page_style,
rec.login_page_style_comp_logo,
rec.login_page_background_type,
rec.login_page_background_color,
rec.login_page_box_color,
rec.theme_style,
_scss_val(rec.login_page_style, 'style_2'),
_scss_val(rec.login_page_style_comp_logo),
_scss_val(rec.login_page_background_type, 'bg_color'),
_scss_val(rec.login_page_background_color, '#ffffff'),
_scss_val(rec.login_page_box_color, '#ffffff'),
_scss_val(rec.theme_style, 'style_1'),
rec.is_sticky_form,
rec.is_sticky_list,
rec.is_sticky_list_inside_form,
rec.is_sticky_pivot,
_scss_val(rec.is_sticky_form),
rec.tab_style,
rec.tab_style_mobile,
rec.horizontal_tab_style,
rec.form_element_style,
rec.search_style,
rec.breadcrumb_style,
rec.progress_style,
rec.progress_height,
rec.progress_color,
rec.checkbox_style,
rec.radio_btn_style,
rec.scrollbar_style,
rec.backend_all_icon_style,
rec.navbar_style,
_scss_val(rec.is_sticky_list),
_scss_val(rec.is_sticky_list_inside_form),
_scss_val(rec.is_sticky_pivot),
_scss_val(rec.tab_style, 'horizontal'),
_scss_val(rec.tab_style_mobile, 'vertical'),
_scss_val(rec.horizontal_tab_style, 'style_4'),
_scss_val(rec.form_element_style, 'style_1'),
_scss_val(rec.search_style, 'collapsed'),
_scss_val(rec.breadcrumb_style, 'style_1'),
_scss_val(rec.progress_style, 'style_1'),
_scss_val(rec.progress_height, '4px'),
_scss_val(rec.progress_color, '#111c43'),
_scss_val(rec.checkbox_style, 'style_1'),
_scss_val(rec.radio_btn_style, 'style_1'),
_scss_val(rec.scrollbar_style, 'style_1'),
_scss_val(rec.backend_all_icon_style, 'style_2'),
_scss_val(rec.navbar_style, 'expanded'),
)