İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
4237 Görünümler

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
Avatar
Vazgeç
En İyi Yanı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. 
Avatar
Vazgeç
Üretici

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.

İlgili Gönderiler Cevaplar Görünümler Aktivite
0
Ağu 25
141
1
Ağu 25
2090
1
Tem 25
2588
2
Tem 25
8024
2
Tem 25
4474