Skip to Content
मेन्यू
This question has been flagged
1 Reply
1589 Views

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
Discard
Best Answer

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
Discard
Author

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

Author

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 Replies Views Activity
2
दिस॰ 24
2695
0
सित॰ 24
741
0
मई 24
1611
1
अग॰ 25
202
1
मई 25
1171