Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
1 Svar
1741 Visninger

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
Kassér
Bedste svar

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
Kassér
Forfatter

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

Forfatter

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 Besvarelser Visninger Aktivitet
2
dec. 24
2858
0
sep. 24
794
0
maj 24
1740
1
aug. 25
615
1
maj 25
1389