İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
5522 Görünümler

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 ?

Avatar
Vazgeç
En İyi Yanıt

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() 
Avatar
Vazgeç
Üretici

It works, thank you Temur

you're welcome

İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Oca 25
1441
0
Tem 22
2471
3
Eyl 20
3157
2
Ara 15
4754
0
Mar 15
3464