是否可以对 XML 页面执行 SQL 查询?
Is it possible to perform an SQL query into an XML page?
我正在尝试编辑从数据库中的 table 收集数据的 XML 报告:
<tr t-foreach="o.order_line" t-as="l">
<td>
<span t-field="l.name"/>
</td>
<td>
...
</td>
...
</tr>
现在,这非常有效,我可以在我的文档中打印 order_line table 的每个字段。
当我尝试打印另一个 table (product_template)
的字段时,我的问题就开始了
我想打印查询结果:
SELECT product_template.product_code [this is NOT the product_id nor a primary key]
FROM product_template, order_line
WHERE
order_line.product_id = product_template.product_id;
此查询 returns 一个 unic 值,它是一个 8 个字符的字符串,应该出现在文档的 <td> ... </td>
字段中。
由于我是 xml 编码和数据库的初学者,因此非常感谢您的帮助。
谢谢
您可以像这样使用点符号:
<tr t-foreach="o.order_line" t-as="l">
<td>
<span t-field="l.name"/>
</td>
<td>
<span t-field="l.product_id.name"/>
<span t-field="l.product_id.product_code"/>
</td>
<!-- [...] -->
</tr>
我正在尝试编辑从数据库中的 table 收集数据的 XML 报告:
<tr t-foreach="o.order_line" t-as="l">
<td>
<span t-field="l.name"/>
</td>
<td>
...
</td>
...
</tr>
现在,这非常有效,我可以在我的文档中打印 order_line table 的每个字段。 当我尝试打印另一个 table (product_template)
的字段时,我的问题就开始了我想打印查询结果:
SELECT product_template.product_code [this is NOT the product_id nor a primary key]
FROM product_template, order_line
WHERE
order_line.product_id = product_template.product_id;
此查询 returns 一个 unic 值,它是一个 8 个字符的字符串,应该出现在文档的 <td> ... </td>
字段中。
由于我是 xml 编码和数据库的初学者,因此非常感谢您的帮助。 谢谢
您可以像这样使用点符号:
<tr t-foreach="o.order_line" t-as="l">
<td>
<span t-field="l.name"/>
</td>
<td>
<span t-field="l.product_id.name"/>
<span t-field="l.product_id.product_code"/>
</td>
<!-- [...] -->
</tr>