Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
21854 Zobrazení

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.

Avatar
Zrušit

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

Nejlepší odpověď


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


Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
3
pro 17
11516
1
čvc 25
1675
1
úno 25
1031
0
led 24
4469
1
pro 17
6187