我想在继承的 qweb 报告模板中向 odoo xpath 查询的所有匹配项添加相同的属性。
我的代码仅将“1.aaa”的颜色更改为红色。(第一个匹配的项目)
我可以将“/*[@class='test_class'][2]”用于第二个项目,但这不是解决方案,因为继承报告中有许多带有“test_class”的项目。
<template id="test_report_document_raw">
<h2 class="test_class">1. aaa</h2>
<h2 class="test_class">2. bbb</h2>
<h2 class="test_class">3. ccc</h2>
...
</template>
<template id="test_report_document" inherit_id="test.test_report_document_raw" primary="True">
<xpath expr="//*[@class='test_class']" position="attributes">
<attribute name="style">color: red;</attribute>
</xpath>
</template