diff --git a/addons/stock/models/stock_quant.py b/addons/stock/models/stock_quant.py index 20a4bd640c6db650e7d9fbe9ef6fe313b61bb5ed..1895bbfdd525f751fe3e6ae95ef20c7b10cb10b7 100644 --- a/addons/stock/models/stock_quant.py +++ b/addons/stock/models/stock_quant.py @@ -405,6 +405,11 @@ class QuantPackage(models.Model): move_line_to_modify.write({'package_id': False}) package.mapped('quant_ids').sudo().write({'package_id': False}) + # Quant clean-up, mostly to avoid multiple quants of the same product. For example, unpack + # 2 packages of 50, then reserve 100 => a quant of -50 is created at transfer validation. + self.env['stock.quant']._merge_quants() + self.env['stock.quant']._unlink_zero_quants() + def action_view_picking(self): action = self.env.ref('stock.action_picking_tree_all').read()[0] domain = ['|', ('result_package_id', 'in', self.ids), ('package_id', 'in', self.ids)]