Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
I have defined my function like this:
retvals = 
for record in self:
if context.get('prod_form', False):
catstring = "[" + record.name + "] " + record.description
I've tried to use "context" by itself, as "self.context", "context.get()", etc. I get errors all around. How do I test to see if a context is set, if I use "self" as the only parameter? Can I just say "def name_get(self, context=None)" ?
Hello Jeff, good question.
As the new API guidelines state, 'cr', 'uid' and 'context' are encapsulated in the new 'Environment' object.
Property attributes are available in the 'Environment' object for 'user' ('self.env.user') and 'lang' ('self.env.lang').
Context values can be retrieved directly as 'self.env.context.get('value_key', value_if_undefined)', sample usage at 'res.partner'
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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 11/7/14, 7:31 PM|
|Seen: 4591 times|
|Last updated: 5/9/16, 8:53 PM|