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

In odoo context dictionary is frozen so no one can update it, for that one solution is also available is calling method using with_context.


ctx = self.env.context.copy()

ctx.update({'additional_parameter' : value})

self.with_context(ctx).methodname()


but when we use the same pattern to call super method then result turns into the infinite call.


ctx = self.env.context.copy()

ctx.update({'additional_parameter' : value})

super(product_product, self).with_context(ctx).create(vals)


Any help will be highly appreciated.

الصورة الرمزية
إهمال
أفضل إجابة

super(product_product, self.with_context(ctx)).create(vals)

الصورة الرمزية
إهمال
أفضل إجابة

hi,

i've had the same problem on odoo9 (and i assume it will be the same in odoo 10+). Simple solution for this - add an other parameter 'i_was_already_here': True to the context - in the same function do check for this paramter at the start - if it does exists - then the context already got updated - and you can call the super call without the context update. So you wont get the infinite loop

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
16
أغسطس 19
9709
1
يناير 19
5071
5
يونيو 18
10451
0
سبتمبر 17
2231
0
فبراير 17
2680