Am 05.05.2015 um 09:26 schrieb Cédric Krier:
On 05 May 08:52, Truckparts Hamburg COM wrote:
Am 04.05.2015 um 22:08 schrieb Udo Spallek:
Mon, 04 May 2015 14:59:15 +0200
Truckparts Hamburg COM <truckparts-hamb...@gmx.de>:
Am 04.05.2015 um 09:58 schrieb Cédric Krier:
On 03 May 13:41, Truckparts Hamburg COM wrote:
Am 02.05.2015 um 18:50 schrieb Cédric Krier:
On 01 May 06:21, TPH wrote:
You need to set the product in context before find locations
Product = Model.get('product.product')
Location = Model.get('stock.location')
(product,) = Product.find([('code', '=', product_code)])
config.context['product'] = product.id
(location,) = Location.find([('type', '=', 'storage'), ("name",
"=", location_name)])
config._context['locations'] = [location.id]
You must not set the context like that but you must use the context
manager of proetus.config.set_context
This part is working. If I not set "config._context['locations']"
product stock is also 0.
If I try "proteus.config.set_context['product'] = product.id" is
get result: AttributeError: 'module' object has no attribute
'set_context'
proteus.config.set_context is a method for a context manager so you
must call it.
Something like:
      with proteus.config.set_context(product=product.id):
Does this work?

     with config.set_context(product=product.id):
         location, = Location.find(
             [
                 ('type', '=', 'storage'),
                 ('name', '=', location_name)])

Best Udo
Hello Udo,

when I call "config.set_context()" I get this message:

AttributeError: 'module' object has no attribute 'set_context'
You must use the Config instance you receive from "set_trytond" or
"set_xmlrpc".

Thank you very much !   It is running now :-)

With Tryton and Proteus 3.2:

"""
xmlrpc_config = proteus.config.set_xmlrpc(url)
xmlrpc_config._context['stock_date_end'] = datetime.date(2015, 4, 30)

Product = Model.get('product.product')
Location = Model.get('stock.location')

(product,) = Product.find([('code', '=', product_code)])
xmlrpc_config.set_context(product=product.id)

(location,) = Location.find([('type', '=', 'storage'), ("name", "=", location_name)])
xmlrpc_config._context['locations'] = [location.id]

print "product quantity:", product.quantity
print "location quantity", location.quantity
"""

regards, Johannes

Reply via email to