Skip to Content
Menu
This question has been flagged
1 Atsakyti
5548 Rodiniai

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 ?

Portretas
Atmesti
Best Answer

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() 
Portretas
Atmesti
Autorius

It works, thank you Temur

you're welcome

Related Posts Replies Rodiniai Veikla
1
saus. 25
1445
0
liep. 22
2498
3
rugs. 20
3160
2
gruod. 15
4754
0
kov. 15
3489