Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
21965 Visualizzazioni

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
Abbandona

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

Risposta migliore


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
Abbandona
Post correlati Risposte Visualizzazioni Attività
3
dic 17
11748
1
lug 25
1899
1
feb 25
1116
0
gen 24
4562
1
dic 17
6271