Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2914 Näkymät

Hi All,
i have a piece of code which working fine it set invoice sequence base on invocie date, let suppose i created invoice on 10/01/2024 so the above code generate sequence ,INV/2024/01/10/0001 ,when created another one INV/2024/01/10/0002 it ok now i want to create invoice on 23/03/2018 INV/2018/03/23/0001,INV/2018/03/23/0002,INV/2018/ 03/23/0003 
 when change the month in invoice date sequence should start form  INV/date/0001


 

py:
def action_post(self): 

rec = super().action_post() for record in self: 

invoice_date = record.invoice_date 

if invoice_date: 

invoice_date_str = format_date(invoice_date, format='yyyy/MM/dd', locale='en_US') next_invoice_sequence = self.env[ 'ir.sequence'].next_by_code('new.invoice. seq') record. name = ' INV/' + invoice_date_str + '/' + str(next_invoice_sequence) 

else: 

record.name = '/' 

record.payment_reference = record.name 

return  rec

xml:

 

    Invoice field > 

    new.invoice.seq field > 

    4 fields > 

    1 field > 

    1 field > 

     

     





Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
maalisk. 24
2463
2
marrask. 23
2313
4
toukok. 25
2052
2
toukok. 25
5365
1
maalisk. 25
1299