mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
update common
This commit is contained in:
@@ -22,7 +22,7 @@ def app_relaxng(view_type):
|
||||
""" Return a validator for the given view type, or None. """
|
||||
if view_type not in _relaxng_cache:
|
||||
# tree, search 特殊
|
||||
if view_type in ['tree', 'search']:
|
||||
if view_type in ['tree', 'search', 'pivot']:
|
||||
_file = get_resource_path('app_common', 'rng', '%s_view.rng' % view_type)
|
||||
else:
|
||||
_file = get_resource_path('base', 'rng', '%s_view.rng' % view_type)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import ast
|
||||
from odoo.tools import view_validation
|
||||
from odoo.tools.view_validation import get_attrs_field_names as old_gafn
|
||||
from odoo.tools.view_validation import _get_attrs_symbols
|
||||
import logging
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
@@ -18,25 +19,42 @@ ATTRS_WITH_FIELD_NAMES2 = {
|
||||
'decoration-primary',
|
||||
'decoration-success',
|
||||
'decoration-warning',
|
||||
'decoration-black',
|
||||
'decoration-white',
|
||||
'bg-danger',
|
||||
'bg-info',
|
||||
'bg-muted',
|
||||
'bg-primary',
|
||||
'bg-success',
|
||||
'bg-warning',
|
||||
'bg-black',
|
||||
'bg-white',
|
||||
}
|
||||
|
||||
def app_get_attrs_field_names(env, arch, model, editable):
|
||||
symbols = _get_attrs_symbols() | {None}
|
||||
result = []
|
||||
|
||||
def add_bg(node, model, editable, get=old_gafn.get_name):
|
||||
def get_name(node):
|
||||
""" return the name from an AST node, or None """
|
||||
if isinstance(node, ast.Name):
|
||||
return node.id
|
||||
|
||||
def process_expr(expr, get, key, val):
|
||||
""" parse `expr` and collect triples """
|
||||
for node in ast.walk(ast.parse(expr.strip(), mode='eval')):
|
||||
name = get(node)
|
||||
if name not in symbols:
|
||||
result.append((name, key, val))
|
||||
|
||||
def add_bg(node, model, editable, get=get_name):
|
||||
for key, val in node.items():
|
||||
if not val:
|
||||
continue
|
||||
if key in ATTRS_WITH_FIELD_NAMES2:
|
||||
old_gafn.process_expr(val, get, key, val)
|
||||
process_expr(val, get, key, val)
|
||||
|
||||
res = old_gafn(arch, model, editable)
|
||||
res = old_gafn(env, arch, model, editable)
|
||||
add_bg(arch, model, editable)
|
||||
res += result
|
||||
return res
|
||||
|
||||
Reference in New Issue
Block a user