跳至内容
菜单
此问题已终结
1 回复
1613 查看

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 ?

形象
丢弃
最佳答案

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)

形象
丢弃
编写者

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

编写者

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)

相关帖文 回复 查看 活动
2
12月 24
2736
0
9月 24
747
0
5月 24
1620
1
8月 25
386
1
5月 25
1233