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

'name':self.env['ir.sequence'].with_context(ir_sequence_date=str(fields.Date.today())[:10]).next_by_code('warehouse.purchase')


Heya newbie in learning odoo backend, i have a question to ask what is the use of with_context in this case? i mean how do i read the code above me? what is the function of with context in this case and next by code in this case

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi Therian,

By passing context in the above code, inside the ir.sequence's function "next_by_code", you can call that context value.
Locate "next_by_code" function inside ir.sequence model, and try to print self.env.context, there should be a key that you have passing through context

print(self.env.context.get('ir_sequence_date'))

Regards,
Ivan

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
3
พ.ค. 20
2346
3
ต.ค. 23
8697
1
ก.ย. 23
3266
1
พ.ค. 23
2228
2
เม.ย. 23
2772