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.

1

Generating Invoices from Incoming Shipments?

By
mike
on 2/19/13, 10:10 AM 3,708 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 :)

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

Ray Carnes

--Ray Carnes--
15717
| 9 7 9
Greater Los Angeles, United States
--Ray Carnes--

Senior Odoo Analyst

OpenERP 6.1, 7.0 and Odoo 8.0, 9.0 (Since 2012)

Completed Functional and Technical Training.

Major Skills:

  • Needs Discovery and Requirements Analysis;

  • Function and Technical Specifications;

  • Project Planning;

  • Prototyping and Proof of concepts;

  • Data migration;

  • Configuration & Customization (UI and modules);

  • Integration - data, business logic and service levels;

  • Training and Knowledge transfer;

  • Go Live support;

  • Help desk;

  • Version Migration.

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. 

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).

2
eLBati
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.

mike
on 7/25/13, 6:06 PM
0
mike
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'
    } 

    vmi_stock_picking()

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).

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

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

Bista Solutions US, 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?

mike
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.

Bista Solutions US, 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?

mike
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.

Bista Solutions US, 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...

mike
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.

Bista Solutions US, 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...

mike
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.

mike
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.

Bista Solutions US, Ray Carnes
on 2/27/13, 1:03 PM
0

Andreas Brueckl

--Andreas Brueckl--
5056
| 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.

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

4 follower(s)

Stats

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