opt app_common 及app_saas 相关,但没检查

This commit is contained in:
Ivan Office
2025-01-26 00:42:35 +08:00
parent 0c93e27528
commit ec4186a53d
13 changed files with 421 additions and 286 deletions

View File

@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
from odoo import api, models, tools, SUPERUSER_ID
from odoo.modules.module import get_resource_path
from odoo.tools import file_open
from odoo.tools import misc
from odoo.tools import view_validation
from odoo.tools.view_validation import _relaxng_cache, validate, _validators
from odoo.tools.safe_eval import safe_eval
@@ -14,10 +15,10 @@ 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']:
_file = get_resource_path('app_common', 'rng', '%s_view.rng' % view_type)
if view_type in ['list', 'search']:
_file = misc.file_path('app_common/rng/%s_view.rng' % view_type)
else:
_file = get_resource_path('base', 'rng', '%s_view.rng' % view_type)
_file = misc.file_path('base/rng/%s_view.rng' % view_type)
with tools.file_open(_file) as frng:
try:
relaxng_doc = etree.parse(frng)
@@ -28,15 +29,15 @@ def app_relaxng(view_type):
return _relaxng_cache[view_type]
view_validation.relaxng = app_relaxng
#
# class View(models.Model):
# _inherit = 'ir.ui.view'
#
# def __init__(self, env, ids, prefetch_ids):
# # 这里应该是无必要,但为了更安全
# super(View, self).__init__(env, ids, prefetch_ids)
# view_validation.relaxng = app_relaxng
#
# # todo: 有可能需要处理增加的 header等标签
# # 直接重写原生方法
# # def transfer_node_to_modifiers(node, modifiers, context=None, in_tree_view=False):
# todo: 有可能需要处理增加的 header等标签
# 直接重写原生方法
# def transfer_node_to_modifiers(node, modifiers, context=None, in_tree_view=False):