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

'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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 5 20
2350
3
thg 10 23
8707
1
thg 9 23
3275
1
thg 5 23
2231
2
thg 4 23
2774