This commit is contained in:
2025-08-19 15:05:55 +07:00
parent 70ae66ee4b
commit f78dc34aee
161 changed files with 13703 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
from . import view_validation
+34
View File
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
import os
import logging
from lxml import etree
from odoo import tools
from odoo.tools.view_validation import validate
_logger = logging.getLogger(__name__)
_schema_validator = {}
def _get_validator(view_type):
""" Return a validator for the given view type, or None. """
if view_type not in _schema_validator:
with tools.file_open(os.path.join('cheat_web', 'rng', '%s_view.rng' % view_type)) as frng:
try:
relaxng_doc = etree.parse(frng)
_schema_validator[view_type] = etree.RelaxNG(relaxng_doc)
except Exception:
_schema_validator[view_type] = None
return _schema_validator[view_type]
@validate('hello', 'statistic', 'cheat')
def view_schema_validation(arch, **kwargs):
""" Get RNG validator and validate RNG file."""
validator = _get_validator(arch.tag)
if validator and not validator.validate(arch):
for error in validator.error_log:
_logger.error("%s", error)
return False
return True