Ajuda

0

Changing stock level of a lot via API

Avatar
Viktor Gruber

Hi all,


I am trying to change stock levels of a product lot via the API (14.0), by supplying the batch name (i.e. "LF-1") and the new quantity.

We are managing product lots with a woocommerce-plugin that I wrote myself. Now I want to sync lots from Odoo to Woocommerce and back in case of orders. I don't need the orders in Odoo, in fact I prefer to have them separate.


To update the lots, I tried the following, but it didn't work:

updated = models.execute_kw(
db, uid, password,
'stock.change.product.qty',
'create',
[{
'product_id': variation_id,
'new_quantity': 3.0,
'product_tmpl_id': product_id
}]
)


Obviously there is no lot number specified, and the documentation of this model doesn't mention any.

Then I tried:

updated = models.execute_kw(
db, uid, password,
'stock.production.lot',
'write',
[[batch['id']]],
{
'product_qty': 3.0,
}
)


Didn't work either, as product_qty is read only.


I would be happy for any suggestion on how to solve this!

Avatar
Descartar
1 Resposta
0
Avatar
Viktor Gruber
Melhor Resposta

Ok I have found a different way, using stock.move, moving products from the warehouse to inventory adjustment and back, but it doesn't work either, as it is automatically assumed that I am moving serial numbers, NOT lots. So if I want to move 5 items from a lot, only one is moved, and 4 are moved without lot information (resulting in corrupted data, as the product has to have a lot number).

This is getting real frustrating...


move = models.execute_kw(
db, uid, password,
'stock.move',
'create',
[{
'company_id': 1,
'product_id': 1,
'lot_ids': [1],
'location_id': 8,
'location_dest_id': 14,
'product_uom_id': 1,
'product_uom_qty': 0,
'qty_done': 5
}]
)
Avatar
Descartar