Skip to Content
Menu
This question has been flagged
1 Reply
9617 Views

Using PHP and the XML RPC Odoo API I would like to update the stock quantity of a product.

To simplify the task of using XML RPC I use the "OdooClient" library by Robroypt:
https://github.com/robroypt/odoo-client

When i try:

 $response = $this->getClient('object')->execute_kw(
      $this->database,
      $this->uid(),
      $this->password,
      'stock.change.product.qty',
      'change_product_qty',
      [[
          'location_id'        => 15,
          'new_quantity'       => (float) 10, //New quantity
          'product_id'         => 157, //My product
          'product_tmpl_id'    => 87, //My product template
      ]]
);

Strangely I get errors like:

DataError: invalid input syntax for integer: "product_tmpl_id"

That doesn't make much sense.


Is it even possible to call methods like "change_product_qty" from the XML RPC API?


My question is similar as this question but mine is for v10:
https://www.odoo.com/forum/help-1/question/update-quantity-on-hand-via-xmlrpc-and-php-82281

Avatar
Discard
Best Answer

First you need to create a stock.change.product.qty record and using this object you have to call change_product_qty function.
In python code will be like:-

wizard = change_qty_wiz.create({
'product_id': product.id,
'new_quantity': float(item.findtext(name)),
'location_id': location.id,
})
wizard.change_product_qty()

Here Wizard is a stock.change.product.qty object.




Avatar
Discard
Related Posts Replies Views Activity
1
Oct 24
274
1
Apr 24
518
2
Mar 24
752
0
Sep 23
577
1
Jun 23
819