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

Im trying some website-programmings and want to display a specific page name on the frontend. Therefore I have the following code:

class wsga(http.Controller):
    @http.route('/hello/', auth="public", type='http', website=True)
    def hello(self, **kw):
        imd = request.registry['ir.model.data']
        iuv = request.registry['ir.ui.view']
        
        cr = request.cr

        view_id = imd.get_object_reference(request.cr, request.uid, 'wsga', 'wsga_test')
        view = iuv.browse(request.cr, request.uid, [('id', '=', view_id), ], context=None)
        
        view_result = []
        for v in view:
            view_result.append({
                'name': v.name,
            })

        return view_result

But the problem is, that this ends up in an SQL-Error in the for-loop. Problem is this query:

SELECT ir_ui_view."create_uid",ir_ui_view."create_date",ir_ui_view."name",ir_ui_view."inherit_id",ir_ui_view."arch",ir_ui_view."write_uid",ir_ui_view."priority",ir_ui_view."application",ir_ui_view."website_meta_description",ir_ui_view."website_meta_title",ir_ui_view."mode",ir_ui_view."write_date",ir_ui_view."id",ir_ui_view."website_meta_keywords",ir_ui_view."model",ir_ui_view."model_data_id",ir_ui_view."type",ir_ui_view."page",ir_ui_view."field_parent" FROM "ir_ui_view"
                        WHERE ir_ui_view.id IN (('id', '=', ('ir.ui.view', 704))) AND (TRUE)
                        ORDER BY priority,name

Problem ist the (('id', '=', ('ir.ui.view', 704))) which I think should be like this (704).

Can anyone help me to understand what went wrong?

Thank you!

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

hi,

you have to change the following line.

 view = iuv.browse(request.cr, request.uid, [('id', '=', view_id), ], context=None)

with new line below.

 view = iuv.browse(request.cr, request.uid, [('id', '=', view_id[1]), ], context=None)

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Thank you for helping. I tested this with return view_id[1] to see wat's the output. 
Sometimes you just can not get the simplest things.

Thank you very much!

อวตาร
ละทิ้ง

Always your welcome :)

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ต.ค. 24
1308
1
มิ.ย. 20
5956
5
ก.ค. 18
6296
0
มี.ค. 15
4294
1
ธ.ค. 24
3923