Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
3784 Vistas

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
Descartar
Mejor respuesta

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
Descartar
Autor

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.

Publicaciones relacionadas Respuestas Vistas Actividad
2
jun 25
1463
0
may 25
12
2
ene 25
3112
1
dic 24
6688
1
nov 24
3066