Skip to Content
Menu
This question has been flagged
1 Reply
5075 Views

I am trying to update the stock of a product at a given location. I have tried creating an entry in stock.change.product.qty however I saw no change in stock levels shown within Odoo. 


I would like to be able to pass in a product_id, location_id, and quantity to set initial stock levels of each product.


Is this possible to do using the XML-RPC API?

Any help would be appreciated.

Avatar
Discard
Best Answer

Hello Jack Buckon

Improvise:

Note sure how you execute through the xml-rpc,

By default manner to update to qty on product, odoo will check the company warehouse and it's location. for that check the below code [Assume you're update the qty on same manner].


import xmlrpc.client


url = '' # URL

database = '' # Database

uid = '' # Username

password = '' # password


common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))

uid = common.authenticate(database, uid, password, {})

models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))


# search the product

product = models.execute_kw(database, uid, password, 'product.product', 'search', [[('id', '=', 285)]])

# Changes the Product Quantity by creating/editing corresponding quant.

stock_change_product_qty_id = models.execute_kw(database, uid, password, 'stock.change.product.qty', 'create', [{

'product_id': 1,

'product_tmpl_id': 285,

'new_quantity': 11,

}])

# Method Trigger: change_product_qty

models.execute_kw(database, uid, password, 'stock.change.product.qty', 'change_product_qty', [stock_change_product_qty_id])


Or if you have any other location to update the product qty, then you can achieved this by the create the inventory adjustment through xml-rpc.

Thanks..

For more information Contact us :-  https://kanakinfosystems.com/odoo-development-services

Avatar
Discard
Author

Thank you, I was missing the method trigger step from my code.

Related Posts Replies Views Activity
1
Nov 24
1484
1
Nov 24
1191
2
Sep 24
1047
1
Aug 24
2453
3
Aug 24
2687