Odoo Help


What is the difference between normal context and _context ?

Anil R. Kesariya
on 6/30/15, 3:10 AM 1,852 views

Hello Everyone,

In odoo , new coding standard we can have two context if we use api.

1) cr,uid, context = self.env.args,

2) self._context

We can get context two way, but value of both convext is different.

What is the different between these two context?




Can you post please what kind of differences you've spotted? Examples?

on 6/30/15, 3:46 AM

_context is frozon dictionary cannot update, like we were able to update till v7, some of the information are different for both context in same method.

Anil R. Kesariya
on 6/30/15, 6:30 AM

Anil R. Kesariya

--Anil R. Kesariya--
| 6 5 8
Rajkot, India
--Anil R. Kesariya--

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

Anil R. Kesariya
On 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.



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

Question tools

3 follower(s)


Asked: 6/30/15, 3:10 AM
Seen: 1852 times
Last updated: 12/5/17, 10:30 PM