我想修改 RFQ 报告,因为我想从 Qweb 报告中调用一个 python 方法,
这里是一些示例代码,
<span t-field ="o.my_custom_fuction()" />
我的 python 函数就像
@api.model
def my_custom_function(self):
return "some_value"
但它给了我这样的错误 qwebException:评估时出现“my_custom_function()”。
知道我遗漏了什么吗?
最佳答案
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()" />
关于python - Odoo qweb调用python方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39474140/