Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
1618 Vizualizări

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 ?

Imagine profil
Abandonează
Cel mai bun răspuns

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)

Imagine profil
Abandonează
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)

Related Posts Răspunsuri Vizualizări Activitate
2
dec. 24
2738
0
sept. 24
747
0
mai 24
1625
1
aug. 25
404
1
mai 25
1246