Hello

I try to find all location containing a product. I need this because until 
now I have to check every location for product stock and this takes about 
30 seconds. I asked something similar 2 years ago, but only found a 
solution to fast get the quantity of a location if I have location 
name: 
https://groups.google.com/forum/#!searchin/tryton/proteus/tryton/JciAJE-3u9A/9BGT4HylytQJ

But I still found no fest way to get all locations with quantity of a 
product. So maybe first step is to get locations with quantity.

I use Tryton with Proteus 3.2 but also can use version 3.8.

What I tried is the following:

    def products_by_location(self, product_code):
        Product = Model.get('product.product')
        Location = Model.get('stock.location')
        product, = Product.find([('code', '=', product_code)])
        self.xmlrpc_config.set_context(stock_date_end = date.today())
        self.xmlrpc_config.set_context(product=product.id)  
        locations = Location.find([('type', '=', 'storage'), ("parent", "=", 
self.default_warehouse)])
        locations_with_product_stock = [(l.name, l.quantity) for l in 
locations if l.quantity]



-- 
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/1716bb15-a3e3-49a7-a8d8-055ff68a5e8f%40googlegroups.com.

Reply via email to