El 22/03/16 a les 13:46, Raimon Esteve ha escrit:
2016-03-22 12:51 GMT+01:00 TPH<truckparts-hamb...@gmx.de>:
>Hello,
>
>I just wrote this question in the German group, but I think here are much
>more people. Ill will keep both articles updated.
>
>What is the best way to get product stock directly from database?
>
>For a webshop / ebay sync I need the stock for every product of the
>warehouse. I have tried this with proteus, but this is not fast enough.
>
>So I am searching for an way, to get the actually stock of product on the
>warehouse.
>
>I think I have to use  "stock_location" and "stock_move". Maybe someone have
>already a snipped or can give me some hints.
https://bitbucket.org/tryton/stock/src/c9a913139d8da1cac5835362b829d16c0d28602f/product.py?fileviewer=file-view-default#product.py-135

It's a method very hard and spend some time depends about
product/stock moves in your database.

Or you can simply browse the list of products with the correct keys in the context:

location_ids = (list of ids of the locations you want to take in account)
product_ids = (list of products id you want no know the stock)

with Transaction().set_context(locations=location_ids):
  for product in Product.browse(product_ids):
    print product.quantity, product.forecast_quantity


Atention with the context because return some values or others.
This is explained on the docstring of compute_quantities [1]

And it affects both ways.

HIH

[1] https://bitbucket.org/tryton/stock/src/c9a913139d8da1cac5835362b829d16c0d28602f/move.py?fileviewer=file-view-default#move.py-878
--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

--
You received this message because you are subscribed to the Google Groups 
"tryton" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/56F1455D.1050705%40koolpi.com.

Reply via email to