Odoo Help


Generating Invoices from Incoming Shipments?

on 2/19/13, 10:10 AM 5,231 views

For 7.0 Our simple use-case involves vendor-managed inventory where we want the vendor to input their picking and be able to generate a draft invoice from it which we then approve after an audit. However, pickings added under incoming shipments cannot be invoiced unless they are related to a purchase order. We do not need the purchase order though. And the extra steps involved for one are unnecessary work in our use-case.

The only way I can find to get around this behavior is to write a trigger function which updates each stock_picking record created with invoice_state = 2binvoiced.

Is there an easier and less ugly solution?

You are missing out on the validation step. The vendor inputs 10 cases. You have 9 in the warehouse. How do you know where the missing case is? Did it come off the truck? Without an order to match with a picking you will never know. Unless you trust your vendors and delivery companies a lot :)

Ray Carnes
on 2/19/13, 1:12 PM

Ray Carnes

--Ray Carnes--
| 9 7 9
Keyport, United States
--Ray Carnes--

Senior ERP Analyst

OpenERP 6.1, 7.0; Odoo 8.0, 9.0, 10.0 and 11.0.

Completed Odoo Functional and Technical Training.

Functional Areas:

  • CRM/Sales

  • Inventory

  • Manufacturing

  • Accounting

  • Purchasing

Major Skills:

  • Business Process Reengineering

  • Efficiency Consulting

  • User Needs and GAP Analysis;

  • Functional and Technical Design;

  • Prototyping and Proof of Concepts;

  • Requirements Specifications;

  • Agile Implementation;

  • Data Migration;

  • Configuration & Customization (UI and code);

  • Integration - Odoo and non Odoo Applications and Services;

  • Training and Knowledge Transfer;

  • Go Live Support;

  • Helpdesk;

  • Version Upgrades and Migration.

  • Accounting Expert.

I have over 20 years of experience empowering and enabling users with enterprise information systems that make a real and measurable difference in their ability to proactively manage their businesses and organizations. 

I am a skilled Communicator and I only take the serious things seriously!

Ray Carnes
On 2/19/13, 1:15 PM

"invoice_state" is on the Incoming Shipment form view, but is invisible.

If you change this to visible, as your vendor enters the picking information, they will be able to manually set it to To Be Invoiced (or you can make this a default for all Incoming Shipments).

On 7/25/13, 6:39 AM

We developed the stock_invoice_picking module, that is currently under testing.

Yo can find it within the lp:~elbati/account-invoicing/adding_stock_invoice_picking_7 branch

This is great! Thank you.

on 7/25/13, 6:06 PM
On 2/19/13, 5:07 PM

Hi Ray

With VMI it is the suppliers responsibility to ensure correct delivery counts and in his best interest to be accurate with contractually agreed minimum and maximum stock levels. We only need to audit a percentage of deliveries to ensure compliance and monitor our demand.

I see where and how to make the field visible and successfully changed it. But I do not see how to make it default to To be Invoiced. I tried Set Defaults but the only value it allows is Not Applicable.

With the DB trigger acting on only inserts of new records the result is the Invoice/Refund button and this is preferable to allowing the invoice state to be changed manually. How else would I set the default so the user is presented with the button?

So this should work? OR do I specify all default fields?

class vmi_stock_picking(osv.osv):

    _name = 'stock.picking'
    _inherit = 'stock.picking'
    _defaults = {
        'invoice_state': '2binvoiced'


You write a python class the inherits the stock.picking model and provides a new default value. DB triggers are certainly one way to change the behavior of OpenERP, but you have complete application level flexibility so should never need to (plus it is much safer to use the application logic).

Ray Carnes
on 2/19/13, 6:38 PM

All your class has to do is define the value. _defaults = { 'invoice_state' : '2binvoiced' }

Ray Carnes
on 2/19/13, 6:44 PM

Ok so I create this class and then do I edit the action of the New form to use my class for it's object?

on 2/20/13, 11:22 AM

Once you create the class that defines a new default, every time a new stock.picking instance is created, it will have that new default. No other changes are needed. This is because you are 'extending' the stock.picking model with your model - in this case your 'extension' is a simple change.

Ray Carnes
on 2/20/13, 12:41 PM

I don't presume to criticize but shouldn't default values for a model reside in the data XML and not hard coded into the model itself?

on 2/21/13, 9:16 AM

Do you know how to do that? I'd love to see a way to do it via XML. Unless you are talking about having them in a Window action context? That is XML. That's another route I think would work without needing a new class.

Ray Carnes
on 2/21/13, 8:00 PM

Maybe this is overkill but I like the idea presented in Listing 5 here - www(dot)ibm(dot)com/developerworks/library/os-pythondescriptors/index.html. With this approach a custom model could have props and vals dynamically set from XML or DB. Somewhat Zopish...

on 2/22/13, 9:28 AM

What you have looks like it should work Mike. Your module approach means all times that an instance of the stock.picking model is created it will have this default, regardless of the client. XML-RPC calls will also use this logic.

Ray Carnes
on 2/26/13, 2:38 PM

It works. I may restrict it to only stock.picking.in though. However, I cannot seem to get the code change to appear on Ubuntu no matter how much I restart server. No problems on Windows though...

on 2/27/13, 10:35 AM

nevermind about Ubuntu problem, I am using an IDE I am not familiar with. When I copy the file over manually and restart the change takes.

on 2/27/13, 11:35 AM

Don't forget to mark your answer as correct (edit it to include the part about making the field visible) - so other readers of this question can understand what solved the problem and so this question can be closed.

Ray Carnes
on 2/27/13, 1:03 PM

Andreas Brueckl

--Andreas Brueckl--

| 7 8 7
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl
On 2/26/13, 4:18 PM

In the PO you should set the field Invoicing Control to Based on incoming shipments. Then the button Create Invoice appears when the incoming shipment has been done.

The created supplier invoice is then based on the quantities which have been shipped.

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

4 follower(s)


Asked: 2/19/13, 10:10 AM
Seen: 5231 times
Last updated: 3/16/15, 8:10 AM