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 >