跳至內容
選單
此問題已被標幟
1 回覆
4980 瀏覽次數

'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

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
3
5月 20
2358
3
10月 23
8718
1
9月 23
3290
1
5月 23
2235
2
4月 23
2780