跳至內容
選單
此問題已被標幟
1 回覆
10480 瀏覽次數

in controller we use --> request.render() method to render qweb template but this isn't working in model how can i render qweb template throug model ??

頭像
捨棄
最佳答案

Hi, here you have a snippet of code that works for me:


def _qweb_render(self, o=None):

    val = {

        'docs': o,

        'doc_model': 'motor.record',

        'doc_ids': [o.id],

    }

    html = self.pool["ir.ui.view"].render(self.env.cr, self.env.uid, 'yourmodule.your_view_xml_id, val, engine='ir.qweb', context=self.env.context).decode('utf8')

    return HTMLSafe(html)

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
3
9月 17
8802
1
7月 25
1956
1
5月 25
2039
1
4月 25
2474
1
2月 25
1744