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

How to send context from models.Model to osv.osv ?

By
Miftah
on 5/16/15, 5:14 AM 873 views

I want to send context when call method in class osv.osv from models.Model (new api) like this :


In models.Model :

ctx = {'key' : 'value'}

self.picking_id.do_transfer(context=ctx)


In osv.osv :

@api.cr_uid_ids_context

def do_transfer(self, cr, uid, picking_ids, context=None):

print "context.get('key')================>>>>>>>>>>>>>>>>",context.get('key')

return True

And result from print is :

context.get('key')================>>>>>>>>>>>>>>>> None


Why the result is None ?

4

Temur

--Temur--
2896
| 6 5 7
Tbilisi, Georgia
--Temur--
Programmer
Temur
On 5/16/15, 6:06 AM

1. there is no difference between osv and Model as osv = Model,  osv is keept for backward compatibility 

2. in v8 there is function with_context() for such cases, use it:

self.picking_id.with_context(key='value').do_transfer() 

It works, thank you Temur

Miftah
on 5/16/15, 9:26 AM

you're welcome

Temur
on 5/16/15, 9:37 AM

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: 5/16/15, 5:14 AM
Seen: 873 times
Last updated: 7/10/15, 10:50 AM