Question

I am developing a custom module for OpenERP 7 that will track hardware installed in various venues. I have the total stock levels recorded in the Warehouse module, but I want to be able to calculate and display amount of each product that is available and the amount that is currently deployed. I'm having trouble figuring out how to do this. I have been looking at this rent module and they seem to do something with stock picking and workflows, but I'm new to OpenERP and not really sure how that works.

The other way I was thinking of was to loop through the deployments and simply calculate the amount of each item, and use functional fields to display it, but I'm not sure if that would even work, or how to do it without hard-coding all the various items.

Was it helpful?

Solution

Have a look at product.py in the stock module, specifically the get_product_available method. This allows you to pack various filter parameters into the context and then it calculates and returns stock as the net of inbound and outbound stock moves.

This method also gets used in the functional fields qty_available, virtual_available, incoming_qty and outgoing_qty. There is reasonably good explanations in the help comments in the module.

OTHER TIPS

In OpenERP, something is in your stock when there's a stock move (object stock.move) with that product to your physical location as destination location, defined on Warehouse object for "Inventory Location" field. Let's say you have recorded 2 moves:

Move 1

Source Location: Supplier
Destination Location: Stock
Qty: 2

Move 2

Source Location: Stock
Destination Location: Deployed Products
Qty: 1

If you open your products list you'll see that you have 1qty of your product available. OpenERP sums all the moves for that product to and from your Stock location. So if you have no other specific needs, recording moves to some sort "Deployed Products" location should be enough.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top