İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
1586 Görünümler

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
Vazgeç
En İyi Yanıt

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
Vazgeç
Üretici

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

Üretici

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)

İlgili Gönderiler Cevaplar Görünümler Aktivite
2
Ara 24
2693
0
Eyl 24
737
0
May 24
1608
1
Ağu 25
192
1
May 25
1162