summaryrefslogtreecommitdiff
path: root/odoo/tools/template_inheritance.py
diff options
context:
space:
mode:
authorJeremy Kersten <jke@odoo.com>2020-01-19 16:17:18 +0000
committerMartin Trigaux <mat@odoo.com>2020-01-20 16:31:09 +0000
commit5198b209f5ebca543cb8c4b20b3a1ffe73dabc7c (patch)
treef088cc78bb158afd9fdc6656beecee21f44dfb11 /odoo/tools/template_inheritance.py
parent54a95099bfc7dc3181bb35a6c03bc350e8bcfb31 (diff)
[IMP] base: improve log for wrong xpath
Before create_multi, in case of invalid syntax used in an XPath, only the problematic record was displayed. It was not ideal for long definition but still usable. Since the views are created using create_multi, the whole file content is displayed in the error traceback, making it almost impossible to locate on files with multiple records. closes odoo/odoo#43590 X-original-commit: 8622469e1fdd4789cc45ed52093d0f329abca14e Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Diffstat (limited to 'odoo/tools/template_inheritance.py')
-rw-r--r--odoo/tools/template_inheritance.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/odoo/tools/template_inheritance.py b/odoo/tools/template_inheritance.py
index ad497d99bb7..33cedf7c12d 100644
--- a/odoo/tools/template_inheritance.py
+++ b/odoo/tools/template_inheritance.py
@@ -3,9 +3,11 @@ from lxml import etree
from lxml.builder import E
import copy
import itertools
+import logging
from odoo.tools.translate import _
from odoo.tools import SKIPPED_ELEMENT_TYPES
+_logger = logging.getLogger(__name__)
def add_text_before(node, text):
@@ -51,7 +53,13 @@ def locate_node(arch, spec):
:return: a node in the source matching the spec
"""
if spec.tag == 'xpath':
- nodes = etree.ETXPath(spec.get('expr'))(arch)
+ expr = spec.get('expr')
+ try:
+ xPath = etree.ETXPath(expr)
+ except etree.XPathSyntaxError:
+ _logger.error("XPathSyntaxError while parsing xpath %r", expr)
+ raise
+ nodes = xPath(arch)
return nodes[0] if nodes else None
elif spec.tag == 'field':
# Only compare the field name: a field can be only once in a given view