Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
11 Replies
9896 Tampilan

Hello, is there a way to make invoices' date be the same as sales orders' date?

We are using Odoo 8 and we have a big problem in terms of creating invoices for our customers and setting the invoice to have the sales order's date would save us so much time and trouble.

If no solution, can we at least change invoice date before printing? This is very labor intensive, but would also do the trick as well.

Thanks a lot for any help and please, if you have questions, don't hesitate to ask me.

Avatar
Buang

How can this be achieved in Odoo 14?

Jawaban Terbai

Hello Again Noah :)

Actually the invoicing date takes the 'current date of pressing the create invoice button' and you can check this here in the wizard 

and this will be passed cross multiple functions starting from here. So to solve this you can change the value of this field 'invoice date' to the SO's date. Or you can modify the function that creates the invoice which you can modify the create dict from here 

Update:

Try to update this line to be as:

'date_invoice': order.date_order or order.create_date or context.get('date_invoice', False),

Hope this will give you some clues ...


Avatar
Buang
Penulis

Hello Ahmed, thanks so much for answering my question. I do understand what you are talking about, but my Python skills are non-existent! Can you please give me lines or pieces of code to change, that would help me a lot.

Just tell me what files to change on my Odoo server, thanks a lot for all your efforts.

Hi, Actually I'vn't Odoo 8 instance right now , I'll try to update my answer later on when it is available ... /

Penulis

Thanks a lot for your very valuable help, I was looking at https://github.com/odoo/odoo/blob/8.0/addons/sale/sale.py#L205 in the hope of understanding where I can get the SO's date snippet, no luck, I have no idea where to start! :)

Hi, I've updated my answer. I'm still can't check this on v8, so check it and feedback :

Penulis

God bless you, it works :) :)

Glad that is works for you :)

Jawaban Terbai

You can change 'invoice date' before you validate an invoice

or try this on code
add this line in 'def _prepare_invoice' function>>invoice_vals ={}

ie in sale.py file line no between 237-250

'date_invoice': order.order_date.date()


Avatar
Buang
Penulis

Yes, this would work, but I'm interested in an automatic solution, with as little human intervention as possible.

Penulis

Thanks for your help.

Jawaban Terbai

Hello Noah,

Your question was the same as my question, but I currently use Odoo 11. I'm grateful for having found the answer from this thread, so I want to share my solution (for Odoo 11.0) instead of creating a new thread.

What I changed in the code is the confirmation_date value, I see that if I change the confirmation_date, the generated stock picking scheduled date will also have the same value, and that is what I need in my case. Then the confirmation date value will be assigned to invoice date as well when I create an invoice based on that sales order. The line affected in the code file is https://github.com/odoo/odoo/blob/11.0/addons/sale/models/sale.py#L523

I changed the code from

'confirmation_date': fields.Datetime.now()

into

'confirmation_date': self.date_order

that's all.

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
1
Nov 16
7583
0
Mar 15
5244
1
Jun 25
2544
3
Mar 25
6508
0
Sep 24
1146