odooqweb调用python方法

2024-10-01 09:19:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我想修改RFQ报告,我想从Qweb报告中调用一个python方法

下面是一些示例代码

<span t-field ="o.my_custom_fuction()" />

我的python函数是

^{pr2}$

但它给我的错误 qwebException:求值时出现“my_custom_function()”。在

有什么线索吗?在


Tags: 方法函数代码示例fieldmy报告错误
1条回答
网友
1楼 · 发布于 2024-10-01 09:19:48

The t-field directive can only be used when performing field access (a.b) on a "smart" record (result of the browse method).

要调用该函数,您需要使用t-esc(接受一个表达式,对其求值并打印内容):

<span t-esc ="o.my_custom_fuction()" />

我用了Odoo QWEB reference

相关问题 更多 >