How to call onchange from python xml rpc, for Odoo 15?

Viewed 23

Hello I want to update a MO product_qty field, but keep all the related records (picking/transfers) synched.

If I write to the record the product_qty gets updated, but not the related record. When doing this manually it works as intended.

I have tried the following, with no success.

update = models.execute_kw(db, uid, password,'mrp.production', 'onchange', [1223,{'product_qty': 10}])
1 Answers

The best thing to do here is more to check in the code what functions are called that have an @api.onchage with at least product_qty in it.

By quick looking in the model with _name = 'mrp.production', I can see 3 of them. Perhaps some other classes that '_inherit' from it can add some, to be verified.

So try this :

update = models.execute_kw(db, uid, password,'mrp.production', '_onchange_product_qty', [[1223]])
update = models.execute_kw(db, uid, password,'mrp.production', '_onchange_move_raw', [[1223]])
update = models.execute_kw(db, uid, password,'mrp.production', '_onchange_move_finished', [[1223]])

There is also the possibility (a bit more rare but exists) that another model has an onchange on its production_id.product_qty e.g.

Looking at relevant models with the Regex Search @api\.onchange.*'product_qty' in both Odoo and Enterprise (if used) can be a good idea ;)

Hope it helps !

Related