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

How can I open a form view in readonly mode after returning the action from python method.

@api.multi
def action_view_product(self):
return {
'type': 'ir.actions.act_window',
'name': 'Products',
'view_mode': 'form',
'view_type': 'form',
'res_model': "product.template",
'res_id': self.id,
'target': 'new',
}


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

Just pass the following code in the action:

'flags': {'initial_mode': 'view'}

return {
'type': 'ir.actions.act_window',
'name': 'Products',
'view_mode': 'form',
'view_type': 'form',
'res_model': "product.template",
'res_id': self.id,
'target': 'new',
'flags': {'initial_mode': 'view'}
}
อวตาร
ละทิ้ง
ผู้เขียน

Thank you, it worked! :)

คำตอบที่ดีที่สุด

Hi,

Can you add this to return and see: 

'context': {'create': False, 'delete': False}

Like:

@api.multi
def action_view_product(self):
return {
'type': 'ir.actions.act_window',
'name': 'Products',
'view_mode': 'form',
'view_type': 'form',
'res_model': "product.template",
'res_id': self.id,
'target': 'new',
'context': {'create': False, 'delete': False},
}

Thanks

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Report in custom module แก้ไขแล้ว
2
มี.ค. 20
5273
1
ต.ค. 18
5325
1
ธ.ค. 17
2488
1
ธ.ค. 17
3985
1
ก.ค. 17
7545