Very low performance on odoo stock operations

Many users incour in very low performance on odoo stock operations transactions.

It can occurs while you validate a delivery order or in a related actions.

It can be also if simply use the function write on stock.move model.

You can see in the log you have a lot of unlink commands like:

odoo.models.unlink deleted stock.picking.package.preparation.line records with ID...

and so on.

This is caused by the stock module trying to check all line relations in model.

You can workaround this behaviour by passing this parameter in context, for example:

move.with_context(skip_update_line_ids=True).write({'owner_id': owner_id.id })

If you find this post useful please leave us a comment, thanks!