Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
2 Respostas
6222 Visualizações

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
Cancelar
Melhor resposta

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
Cancelar
Autor

Thank you, it worked! :)

Melhor resposta

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
Cancelar
Publicações relacionadas Respostas Visualizações Atividade
2
mar. 20
5199
1
out. 18
5280
1
dez. 17
2446
1
dez. 17
3923
1
jul. 17
7509