Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
1636 Представления

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)

Related Posts Ответы Просмотры Активность
2
дек. 24
2752
0
сент. 24
748
0
мая 24
1635
1
авг. 25
463
1
мая 25
1287