From 0f57f0705a3c4c5ca835e435d36816fe907ef9de Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Tue, 16 Jul 2019 11:32:27 +0000 Subject: [PATCH] [FIX] stock: qty_available at date company owned should take into account inventory/production location with companies used in avco/standard at date followup of rev 67ea26460ff27d6a069f8a34c5f5c713049b2a71 opw-2027859 --- addons/stock/models/product.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) 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):