Odoo Help


3 Answers

Anil R. Kesariya (AKE) India

--Anil R. Kesariya (AKE)--
| 8 7 10
Rajkot, India
--Anil R. Kesariya (AKE)--

Odoo Techno Functional Expert

* Engaged with odoo since May - 2012.

* Customise existing module or develop new module base on customer requirement.

* Played key developer role in many past and running projects.

* Expert in requirement gathering of business and transforming requirement into odoo platform.

* Major expertise in core modules, database, report development and theme development.

* Integration expert.

Linkedin  : https://in.linkedin.com/in/anil-kesariya-97b20a66

Upwork : https://www.upwork.com/fl/anilkesariya

Anil R. Kesariya (AKE) India
7/7/15, 12:50 PM

Hi Everyone,

When we extract both context which is implicity passed in any method having same information.


cr, uid, context = self.env.args


Both having same information even if you have passed any external key from client side, you will get the same in both context.

But first different I have suspected is,

while I was using context with recursion:

I was trying to passed the external key to context which is frozon dictionary or self._context to access info inside the same method.

by using with_context we can directly pass the our key to frozone dictionory or self._context

So, it was not showing the key in the next call of same method (Recursion).

Here is the syntax to pass any key using with_context


def custom_method(self)
#code here..
print "_context",self._context #so here i was not able to get the external key in next call.
if condition:
return True
self.with_context(key=value).custom_method() #recusrion

I found solution for it which works for me. Here is the sample example.

from openerp.tools import misc

def custom_method(self):
cr, uid, context = self.env.args

print "Context ::::",context
if condition:
return True
context = dict(context)
self.env.args = cr, uid, misc.frozendict(context)

This is how I passed external key and got it, in the very next call of that function which was called within function.

Correct me if I am wrong!

If i will come up with more differences will update here.



Ask a Question
Keep Informed
3 follower(s)
About This Community

This platform 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.

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now