Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
10456 มุมมอง

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)

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
3
ก.ย. 17
8783
1
ก.ค. 25
1844
1
พ.ค. 25
1927
QWeb: use t-if to check birthday date แก้ไขแล้ว
1
เม.ย. 25
2372
1
ก.พ. 25
1663