diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py index 02a2d39ec5b..f3e895ec7dd 100644 --- a/addons/stock/models/product.py +++ b/addons/stock/models/product.py @@ -160,9 +160,23 @@ class Product(models.Model): company_id = self.env.user.company_id.id return ( [('location_id.company_id', '=', company_id), ('location_id.usage', 'in', ['internal', 'transit'])], - [('location_id.company_id', '=', False), ('location_dest_id.company_id', '=', company_id)], - [('location_id.company_id', '=', company_id), ('location_dest_id.company_id', '=', False), - ]) + ['&', + ('location_dest_id.company_id', '=', company_id), + '|', + ('location_id.company_id', '=', False), + '&', + ('location_id.usage', 'in', ['inventory', 'production']), + ('location_id.company_id', '=', company_id), + ], + ['&', + ('location_id.company_id', '=', company_id), + '|', + ('location_dest_id.company_id', '=', False), + '&', + ('location_dest_id.usage', 'in', ['inventory', 'production']), + ('location_dest_id.company_id', '=', company_id), + ] + ) location_ids = [] if self.env.context.get('location', False): if isinstance(self.env.context['location'], pycompat.integer_types):