コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
5540 ビュー

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 ?

アバター
破棄
最善の回答

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

you're welcome

関連投稿 返信 ビュー 活動
1
1月 25
1443
0
7月 22
2496
3
9月 20
3159
2
12月 15
4754
0
3月 15
3488