Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
1587 Widoki

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 ?

Awatar
Odrzuć
Najlepsza odpowiedź

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)

Awatar
Odrzuć
Autor

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

Autor

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)

Powiązane posty Odpowiedzi Widoki Czynność
2
gru 24
2693
0
wrz 24
738
0
maj 24
1609
1
sie 25
192
1
maj 25
1162