Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update a product field "Quantity On Hand" with xmlrpc

I am trying to update some information on my odoo product with PHP and xmlrpc. This is my code for update product name.

$models->execute_kw($db, $uid, $password, 'product.product', 'write',
    array(array(5), array('name'=>"Newer product 3",'type'=>"consu")));

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

$models->execute_kw($db, $uid, $password, 'product.product', 'write',
    array(array(5), array('name'=>"Newer product 3",'type'=>"consu",'qty_available'=>'7')));

but it doesn't work, anyone got any ideas how to fix it? Thank you.

like image 794
Adreato Avatar asked Dec 03 '25 13:12

Adreato


2 Answers

The field qty_available is readonly. On odoo10 you can use the following operation, python:

product = models.execute_kw(db, uid, password, 'product.product', 'search', [[('default_code', '=', sku)]])
change_id = models.execute_kw(db, uid, password, 'stock.change.product.qty', 'create', [{
                'product_id': product[0],
                'location_id': 15,
                'new_quantity': 20,
                }])

models.execute_kw(db, uid, password, 'stock.change.product.qty', 'change_product_qty', [change_id])
like image 51
Flowf Avatar answered Dec 05 '25 11:12

Flowf


Since the field qty_available is read only there is no way to update it. To update it you'll need to create a stock move

like image 35
rekobeko Avatar answered Dec 05 '25 11:12

rekobeko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!