Se rendre au contenu
Menu
Cette question a été signalée
4 Réponses
9033 Vues

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?

Avatar
Ignorer

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

Meilleure réponse

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

Avatar
Ignorer
Meilleure réponse

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

Avatar
Ignorer
Auteur

This is great! Thank you.

Auteur Meilleure réponse

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()
Avatar
Ignorer

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

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

Auteur

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?

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.

Auteur

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?

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.

Auteur

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

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.

Auteur

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

Auteur

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.

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.

Meilleure réponse

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.

Avatar
Ignorer
Publications associées Réponses Vues Activité
1
nov. 24
19601
0
août 22
12900
1
déc. 21
7531
3
déc. 19
7317
1
mai 19
3539