Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
15305 มุมมอง

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
16
ส.ค. 19
10252
1
ม.ค. 19
5507
5
มิ.ย. 18
10916
0
ก.ย. 17
2548
0
ก.พ. 17
3060