Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to add delivery order number in invoice?

By
Pavel Pavlov
on 12/6/14, 11:33 AM 2,480 views

Hello,

I'm using openERP 7 and I'm having following process for processing new customer orders.
1) Open Sales Order 
2) From the Sales Order, create Delivery Order
3) Back to the Sales Order and create Invoice

So far this process worked. Now I have new customer, who wants to have in his invoice(step 3), the Delivery Order no.(that was crated in step 2). 
The problem is that in sale.order model(db table sale_order) and account.invoice model(db table account_invoice) there is no reference to the delivery order id(db field stock.picking.name). I can't find a option to refer to the stock.picking.name for my sales order from the invoice template, when I modify it with OpenOffice Writer. I can get the o.origin, which returns only the Sales Order No, but from there I can't refer to the Delivery Order no, because it's not in sale.order model. How can I add the Delivery Order number to the Invoice? Has someone done that? 
Looking forward to your replays! Thanks!

Regards,
Pavel

Hi, Maybe in order to access the delivery order no, I have to add it to the account or sales order models...  Maybe I should add to the account.invoice object new column with type related or many2one (https://doc.odoo.com/trunk/server/03_module_dev_02/) Someting like: class account_invoice(osv.osv): .... _columns = { 'delvery_order_name': fields.related( 'delvery_order_name': fields.related('origin', 'name', type="many2one", relation="sales.order" string="DeliveryOrder", store=False) } Has someone tried doing that somehow to mapp account invoice object to the stock.picking object via the sales.order object? Is there smarter way to do that? Regards. Pavel

Pavel Pavlov
on 12/6/14, 12:18 PM

Morning everyone! I still have not found solution for that. I'm now checking the features & code of v8, so in case this is already implemeted there I would have to migrate to v8. Has someone achieved that in v7 or v8 somehow? I'm still not sure I have the proper solution in mind... Thanks! Regards, Pavel

Pavel Pavlov
on 12/8/14, 2:18 AM
0
Pavel Pavlov
On 12/12/14, 12:26 PM

Hello,

It apperas that this is possible with standard. I could acheive it by switching to odoo v8 and changing the process from the described in the question to Generate Sales Order -> Generate Delivery Order -> Generate Invoice(but from the Delivery Order page, not from the sales order. This solves my problem and the invoice in v8 has the delivery order item in the default template. Looks like I will have to switch to V8. 

Regards,
Pavel

0

Ivan

--Ivan--
3210
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
On 12/8/14, 3:00 AM

Currently there is no sure way for you to determine which invoice is created from which delivery order.  If you check the _prepare_invoice methods from odoo/addons/stock/stock.py you'll see that the picking.name is stored into the account.invoice's name.  But this can be overriden by other modules.   If you what to be very sure, then create a many2many relationship between stock.picking and account.invoice and you can play around with the _invoice_hook or _prepare_invoice methods from stock.picking to populate the relationship.  It is called when you clicked the Create Invoice button.

Hi Ivan, which version is that? In my addons/stock/stock.py there is no prepare_invoice method. I'm looking in v8 at the moment. Regards, Pavel

Pavel Pavlov
on 12/8/14, 2:44 PM

I'm looking through v7 of the code. For v8 try the stock_account module. Create Invoice button eventually calls action_invoice_create method in addons/stock_account/stock.py. There are _get_invoice_vals and _create_invoice_from_picking that seems to be parallel of _prepare_invoice and _invoice_hook of old. But, I haven't really tested it myself.

Ivan
on 12/8/14, 10:15 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 12/6/14, 11:33 AM
Seen: 2480 times
Last updated: 3/16/15, 8:10 AM