Files
gzth/header_search_panel/override_relaxng.py
T
2025-12-19 15:37:59 +08:00

22 lines
696 B
Python

# -*- coding: utf-8 -*-
import os
import logging
from lxml import etree
from odoo import tools
from odoo.tools import view_validation
_logger = logging.getLogger(__name__)
_relaxng_cache = view_validation._relaxng_cache
_relaxng_cache['search'] = None
with tools.file_open(os.path.join(os.path.dirname(__file__), 'rng', 'search_view.rng')) as frng:
try:
text = frng.read()
relaxng_doc = etree.fromstring(text.encode('utf-8'))
_relaxng_cache['search'] = etree.RelaxNG(relaxng_doc)
except Exception as error:
_logger.exception('Failed to load RelaxNG XML schema for views validation, {error}'.format(error=error))
_relaxng_cache['search'] = None