Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
4984 Vizualizări

'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

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
3
mai 20
2359
3
oct. 23
8719
1
sept. 23
3292
1
mai 23
2236
2
apr. 23
2781