Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3092 มุมมอง

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 > 

     

     





อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
มี.ค. 24
2690
2
พ.ย. 23
2499
4
พ.ค. 25
2538
2
พ.ค. 25
5916
1
มี.ค. 25
1699