跳至内容
菜单
此问题已终结
1 回复
5973 查看

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.

形象
丢弃

Hello; 

Can you please provide useful resources or documentation about the models name, function ,excepted args and returns of Odoo ?

最佳答案

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

形象
丢弃
编写者

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

相关帖文 回复 查看 活动
2
1月 25
2239
1
11月 24
2393
1
11月 24
1805
2
9月 24
1654
1
8月 24
3328