Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
21432 มุมมอง

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.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Problem using "self.env.user" แก้ไขแล้ว
2
ม.ค. 18
8746
2
ก.ย. 24
44
2
ส.ค. 24
1510
self search based on field แก้ไขแล้ว
2
ก.พ. 23
12720
0
ก.พ. 23
2886