El 29/04/2015 14:55, "TPH" <truckparts-hamb...@gmx.de> va escriure:
>
>
>>
>> Am Samstag, 11. April 2015 13:05:05 UTC+2 schrieb Cédric Krier:
>>>
>>> On 09 Apr 03:16, TPH wrote:
>>> > Hello
>>> >
>>> > Please, how can I get the location / locations of a product in Tryton
?
>>>
>>> A product doesn't have a unique location. But what you can do is to
>>> browse the locations with a 'product' id in the context and read the
>>> 'quantity' of the locations.
>
>
> Thank you. This is also an option for me.
> Would you be so kind and have a look at my example code, I can't get it
running, "product.quantity" is shown but not "location.quantity":
>
>>> location_name = "Box 32"
>>> product_code = "810101000"
>>>
>>> config = config.set_xmlrpc(url)
>>>
>>> Product = Model.get('product.product')
>>> Location = Model.get('stock.location')
>>>
>>> (location,) = Location.find([('type', '=', 'storage'), ("name", "=",
location_name)])
>>> config._context['locations'] = [location.id]
>>>
>>> (product,) = Product.find([('code', '=', product_code)])
>>>
>>> print "product name:", product.name
>>> print "product quantity:", product.quantity
>>>
>>> config.context['product'] = product.id
>>>
>>> print "location name:", location.name
>>> print "location quantity", location.quantity

You need to set the product in context before find locations

Reply via email to