diff --git a/addons/web/static/src/core/assets.js b/addons/web/static/src/core/assets.js
index a7f1786ff6a..6d161bb0b57 100644
--- a/addons/web/static/src/core/assets.js
+++ b/addons/web/static/src/core/assets.js
@@ -231,7 +231,12 @@ registry.category("xml_templates").addEventListener("UPDATE", (ev) => {
if (doc.querySelector("parsererror")) {
// The generated error XML is non-standard so we log the full content to
// ensure that the relevant info is actually logged.
- throw new Error(doc.querySelector("parsererror").textContent.trim());
+ let strError = "";
+ const nodes = doc.querySelectorAll("parsererror");
+ for (const node of nodes) {
+ strError += node.textContent.trim() + "\n";
+ }
+ throw new Error(strError);
}
for (const element of doc.querySelectorAll("templates > [t-name]")) {
diff --git a/odoo/addons/base/models/assetsbundle.py b/odoo/addons/base/models/assetsbundle.py
index 86141a82a4c..4ce7b682d71 100644
--- a/odoo/addons/base/models/assetsbundle.py
+++ b/odoo/addons/base/models/assetsbundle.py
@@ -902,7 +902,7 @@ class XMLAsset(WebAsset):
try:
root = etree.fromstring(content.encode('utf-8'), parser=parser)
except etree.XMLSyntaxError as e:
- return f'Invalid XML template: {self.url} \n {e.msg} '
+ return f'Invalid XML template: {self.url} \n {e.msg} '
if root.tag in ('templates', 'template'):
return ''.join(etree.tostring(el, encoding='unicode') for el in root)
return etree.tostring(root, encoding='unicode')
diff --git a/odoo/addons/test_assetsbundle/__manifest__.py b/odoo/addons/test_assetsbundle/__manifest__.py
index 632291e2ef7..9e649984cd4 100644
--- a/odoo/addons/test_assetsbundle/__manifest__.py
+++ b/odoo/addons/test_assetsbundle/__manifest__.py
@@ -65,6 +65,10 @@
'test_assetsbundle.broken_xml': [
'test_assetsbundle/static/invalid_src/xml/invalid_xml.xml',
],
+ 'test_assetsbundle.multiple_broken_xml': [
+ 'test_assetsbundle/static/invalid_src/xml/invalid_xml.xml',
+ 'test_assetsbundle/static/invalid_src/xml/second_invalid_xml.xml',
+ ],
},
'license': 'LGPL-3',
}
diff --git a/odoo/addons/test_assetsbundle/static/invalid_src/xml/invalid_xml.xml b/odoo/addons/test_assetsbundle/static/invalid_src/xml/invalid_xml.xml
index 51408a14070..ccc458b8ec4 100644
--- a/odoo/addons/test_assetsbundle/static/invalid_src/xml/invalid_xml.xml
+++ b/odoo/addons/test_assetsbundle/static/invalid_src/xml/invalid_xml.xml
@@ -1,6 +1,6 @@
-
+
content
diff --git a/odoo/addons/test_assetsbundle/static/invalid_src/xml/second_invalid_xml.xml b/odoo/addons/test_assetsbundle/static/invalid_src/xml/second_invalid_xml.xml
new file mode 100644
index 00000000000..a5ba63906c4
--- /dev/null
+++ b/odoo/addons/test_assetsbundle/static/invalid_src/xml/second_invalid_xml.xml
@@ -0,0 +1,7 @@
+
+
+
+
+ content
+
+
diff --git a/odoo/addons/test_assetsbundle/tests/test_assetsbundle.py b/odoo/addons/test_assetsbundle/tests/test_assetsbundle.py
index 754a71469bd..665224c9f6a 100644
--- a/odoo/addons/test_assetsbundle/tests/test_assetsbundle.py
+++ b/odoo/addons/test_assetsbundle/tests/test_assetsbundle.py
@@ -638,10 +638,21 @@ class TestXMLAssetsBundle(FileTouchable):
"""
self.bundle = self._get_asset('test_assetsbundle.broken_xml')
- # there shouldn't be any test_assetsvundle.invalid_xml template.
+ # there shouldn't be any test_assetsbundle.invalid_xml template.
# there should be an parsing_error template with the parsing error message.
self.assertEqual(self.bundle.xml(),
- 'Invalid XML template: /test_assetsbundle/static/invalid_src/xml/invalid_xml.xml \n Opening and ending tag mismatch: SomeComponent line 4 and t, line 5, column 7 ',
+ 'Invalid XML template: /test_assetsbundle/static/invalid_src/xml/invalid_xml.xml \n Opening and ending tag mismatch: SomeComponent line 4 and t, line 5, column 7 ',
+ "the parsing error should be shown")
+
+ def test_02_multiple_broken_xml(self):
+ """ Checks that a bundle with multiple broken xml returns a comprehensive error message.
+ """
+ self.bundle = self._get_asset('test_assetsbundle.multiple_broken_xml')
+
+ # there shouldn't be any test_assetsbundle.invalid_xml template or test_assetsbundle.second_invalid_xml template.
+ # there should be two parsing_error templates with the parsing error message for each file.
+ self.assertEqual(self.bundle.xml(),
+ 'Invalid XML template: /test_assetsbundle/static/invalid_src/xml/invalid_xml.xml \n Opening and ending tag mismatch: SomeComponent line 4 and t, line 5, column 7 Invalid XML template: /test_assetsbundle/static/invalid_src/xml/second_invalid_xml.xml \n XML declaration allowed only at the start of the document, line 2, column 6 ',
"the parsing error should be shown")