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

I want to update the available stock of a product, this is what I have:


    data = {
'product_id':product_rec.id,
'location_id': location_rec.id,
'inventory_quantity':product_qty
}
    self.env['stock.quant'].sudo().create(data)

Doesn't seem to update anything.
Thank you
形象
丢弃
最佳答案

Hi Andreas.
Instead of 'inventory_quantity' , use quantity just like:

 self.env['stock.quant'].sudo().create({
'product_id':product_rec.id,
'location_id': location_rec.id,
'quantity':product_qty
})


But this is not the valid way for stock increase technique. Use a Odoo standard way for updating the stock. Please check the update quantity functionality from odoo base code.

For your internal programming, Hope it will help you. 
形象
丢弃
编写者

Hi,
I changed 'inventory_quantity' to quantity but I still don't see any update in the product.
I also tried with _update_available_quantity() but no change.

Malay, could you please provide any pointers you have about the "update quantity functionality from odoo base code"? Something like GithHub source or documentation links.

相关帖文 回复 查看 活动
0
5月 25
11
2
1月 25
2329
1
12月 24
6035
1
11月 24
2469
1
11月 24
1846