Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

Pass context in calling of super method.

By
Emipro Technologies Pvt. Ltd.
on 7/1/15, 10:33 AM 1,476 views

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 {}

Solanki Shamji
on 8/14/15, 1:17 AM
1

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 8/14/15, 1:29 AM


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


Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 7/1/15, 10:33 AM
Seen: 1476 times
Last updated: 4/12/16, 1:19 AM