From 737e9076bab587d8701c17f41de9ac3d7c19b1d4 Mon Sep 17 00:00:00 2001 From: "Tiffany Chang (tic)" Date: Fri, 2 Oct 2020 13:07:11 +0000 Subject: [PATCH] [FIX] stock: fix quant check when archiving location Quant search domain was missing a '|', this made it so locations with non-zero quants in it could still be archived. Also added a missing space in warning message when there are multiple locations because it's better that way. Discovered during task: 2336455 closes odoo/odoo#59154 X-original-commit: 340dac3b2928da292c6b74971e77816304b263ab Signed-off-by: Arnold Moyaux --- addons/stock/models/stock_location.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/stock/models/stock_location.py b/addons/stock/models/stock_location.py index cd2b7643aa2..5013038e686 100644 --- a/addons/stock/models/stock_location.py +++ b/addons/stock/models/stock_location.py @@ -109,10 +109,10 @@ class Location(models.Model): if not self.env.context.get('do_not_check_quant'): children_location = self.env['stock.location'].with_context(active_test=False).search([('id', 'child_of', self.ids)]) internal_children_locations = children_location.filtered(lambda l: l.usage == 'internal') - children_quants = self.env['stock.quant'].search([('quantity', '!=', 0), ('reserved_quantity', '!=', 0), ('location_id', 'in', internal_children_locations.ids)]) + children_quants = self.env['stock.quant'].search(['&', '|', ('quantity', '!=', 0), ('reserved_quantity', '!=', 0), ('location_id', 'in', internal_children_locations.ids)]) if children_quants and values['active'] == False: raise UserError(_('You still have some product in locations %s') % - (','.join(children_quants.mapped('location_id.name')))) + (', '.join(children_quants.mapped('location_id.name')))) else: super(Location, children_location - self).with_context(do_not_check_quant=True).write({ 'active': values['active'],