コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
21619 ビュー

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


アバター
破棄
関連投稿 返信 ビュー 活動
3
12月 17
11334
1
2月 25
818
0
3月 24
1451
0
1月 24
4300
1
12月 17
6009