Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
1 Responder
1651 Visualizações

In any python method How can I know the current view id 
when I use an inherited form 
or just the original form 

can any one help me in this ?

Avatar
Cancelar
Melhor resposta

Hi Ahmed,

Try this code :


def your_method_name(self): 

​view_id = self.env.context.get('view_id') 

​if view_id:

​original_view = self.env['ir.ui.view'].browse(view_id)

Avatar
Cancelar
Autor

unfortunately, not working every time the view_id came with None value.

Autor

any thing can I add it in the view xml to get value for the view_id ??

Hi Ahmed,

Can you try this one.

@api.model
def custom_method(self):
params = self.env.context.get('params', {})
view_id = params.get('view_id')
if view_id:
view = self.env['ir.ui.view'].browse(view_id)

Publicações relacionadas Respostas Visualizações Atividade
2
dez. 24
2764
0
set. 24
751
0
mai. 24
1644
1
ago. 25
495
1
mai. 25
1298