Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
6270 Widoki

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


Awatar
Odrzuć
Najlepsza odpowiedź

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'}
}
Awatar
Odrzuć
Autor

Thank you, it worked! :)

Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
mar 20
5244
1
paź 18
5301
1
gru 17
2482
1
gru 17
3959
1
lip 17
7523