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

I used self.env.context.get('secondary_qty') to fetched the pieces but why it returns None?


What are the possible reasons that it will return None ?

アバター
破棄

Hello, did you solve this problem? Cause right now, Im facing similar problem

最善の回答

Hi,

Self.env.context.get() method is used in order to check whether that key is present in our context. So make sure that your context have this field and its value. Just try to print the context and check the field and its values is there.
context = self.env.context
if context.get('secondary_qty'):       

 print("YES")        

 other operations

アバター
破棄
著作者

Yes,thank u, the field I'm trying to fetch doesn't have any value

最善の回答

Hi,
Since secodary qty is note default context, please check if you pass the context before calling the method. To pass the context you can use with_context() method
ex:
self.with_context(secondary_qty='value').write()

I think you can also print out self.env.context to check what context you have.

アバター
破棄
関連投稿 返信 ビュー 活動
2
1月 18
8699
2
9月 24
44
2
8月 24
1475
2
2月 23
12667
0
2月 23
2848