跳至內容
選單
此問題已被標幟
1 回覆
1653 瀏覽次數

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
2764
0
9月 24
751
0
5月 24
1645
1
8月 25
497
1
5月 25
1300