Update Quantity on Hand via XMLRPC and PHP odoo V14

Viewed 239

I want to change a "Quantity On Hand" field so I trying this code:

   $change_id = $models->execute_kw($db, $uid, $password,
        'stock.change.product.qty', 'create',
        array(array(
            'product_id'=>11745,
            'location_id'=>15,
            'new_quantity'=>26,
            )
        ));
        $models->execute_kw($db, $uid, $password, 'stock.change.product.qty', 'change_product_qty', [$change_id]);

But it doesn't work. How can I fix it?

enter image description here

1 Answers

For changing stock quantity for products you need to create a stock.quant record.

   $models->execute_kw($db, $uid, $password,
        'stock.quant', 'create',
        array(array(
            'product_id'=>11745,
            'location_id'=>15,
            'inventory_quantity'=>26,
            )
        ));

Also keep in mind that directly changing the stock quantity is not recommended, it should be changed from a purchase order or a sale order or from production or inventory adjustments based on the situation.

Related