Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
10458 Lượt xem

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 ??

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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)

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 9 17
8783
1
thg 7 25
1848
1
thg 5 25
1931
1
thg 4 25
2373
1
thg 2 25
1664