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

I want to pass context inside super method calling.

For ex.

@api.multi

def write(self, vals)

    ctx = self._context or {}

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

    res = super(product_product, self).with_context(ctx).write(vals) # It is going into infinite recursion.

#    res = super(product_product, self).write(vals).with_context(ctx) # It is not passing updated context to super method. 

    return res

Any one give proper way to pass context in super method call ?

thanks.

Аватар
Відмінити

Try with this context = self._context.copy() or {}

Найкраща відповідь


Pass and get context value code:-


@api.multi
def write(self, values):
self = self.with_context(key='value')
res = super(product_product, self).write(values)
#print "Get Context value", self._context.get('key')
return res


Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
3
груд. 17
11485
1
лют. 25
975
0
бер. 24
1560
0
січ. 24
4459
1
груд. 17
6168