تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
1648 أدوات العرض

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
ديسمبر 24
2761
0
سبتمبر 24
751
0
مايو 24
1642
1
أغسطس 25
490
1
مايو 25
1297