Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
3965 Lượt xem

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
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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. 
Ảnh đại diện
Huỷ bỏ
Tác giả

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.

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 7 25
3287
2
thg 7 25
3013
2
thg 6 25
1806
0
thg 5 25
14
2
thg 1 25
3368