Skip to Content
Menu
This question has been flagged
2 Replies
4558 Views

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',
}


Avatar
Discard
Best Answer

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'}
}
Avatar
Discard
Author

Thank you, it worked! :)

Best Answer

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

Avatar
Discard
Related Posts Replies Views Activity
2
Mar 20
3964
1
Oct 18
3873
1
Dec 17
1820
1
Dec 17
2937
1
Jul 17
6629