Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
15276 Переглядів

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
10226
1
січ. 19
5487
5
черв. 18
10888
0
вер. 17
2527
0
лют. 17
3029