我有一个看板视图,其中有一个模板在odoo12中,我需要访问那里的python方法数据,以便在表中打印它们。我的python方法返回键值对的字典。在
我使用t-foreach如下:
这是我模型中的方法:
^{pr2}$
在我的模板中,在页面加载时的方法调用中,我遇到了以下错误:Uncaught Error: QWeb2 - template['kanban-box']: Runtime Error: TypeError: dict.get_departments is not a function
http://localhost:8000/web/content/862-f2fdf49/web.assets_common.js:3374
Traceback:
Error: QWeb2 - template['kanban-box']: Runtime Error: TypeError: dict.get_departments is not a function
at Object.exception (http://localhost:8000/web/content/862-f2fdf49/web.assets_common.js:3374:7)
at Engine.eval (eval at _render (http://localhost:8000/web/content/862-f2fdf49/web.assets_common.js:3416:73), :114:29)
at Engine._render (http://localhost:8000/web/content/862-f2fdf49/web.assets_common.js:3415:296)
at Engine.render (http://localhost:8000/web/content/862-f2fdf49/web.assets_common.js:3415:151)
at Engine._render (http://localhost:8000/web/content/862-f2fdf49/web.assets_common.js:3419:57)
at Engine.render (http://localhost:8000/web/content/862-f2fdf49/web.assets_common.js:3415:151)
at Class._render (http://localhost:8000/web/content/901-66db042/web.assets_backend.js:1804:451)
at Class.start (http://localhost:8000/web/content/901-66db042/web.assets_backend.js:1794:1256)
at Class.prototype. [as start] (http://localhost:8000/web/content/862-f2fdf49/web.assets_common.js:3538:488)
at http://localhost:8000/web/content/862-f2fdf49/web.assets_common.js:3683:52
由于错误显示,我的python方法似乎无法在模板中访问,因此我可能需要定义一个JavaScript方法来访问python方法数据。有没有办法在看板视图的模板中直接访问python方法?如果是,我该怎么做?在