Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
21323 Lượt xem

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 ?

Ảnh đại diện
Huỷ bỏ

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

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 1 18
8708
2
thg 9 24
44
2
thg 8 24
1482
2
thg 2 23
12671
0
thg 2 23
2851