From 7a45f6dbeec3c3e02cb6fef0eb1a6c87f222a19c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 21 Mar 2021 15:49:07 +0100 Subject: [PATCH] Add product_cost_warehouse module issue9312 review291641002 --- exceptions.py | 4 ++++ product.py | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/exceptions.py b/exceptions.py index 2933239c6c..de1ece4150 100644 --- a/exceptions.py +++ b/exceptions.py @@ -8,6 +8,10 @@ class AssignError(UserError): pass +class MoveValidationError(ValidationError): + pass + + class LocationValidationError(ValidationError): pass diff --git a/product.py b/product.py index a1836581b2..d0e6052b35 100644 --- a/product.py +++ b/product.py @@ -285,13 +285,16 @@ class Product(StockMixin, object, metaclass=PoolMeta): ('state', '=', 'done'), ] + @classmethod + def _domain_storage_quantity(cls): + "Returns the domain for locations to use in cost computation" + return [('type', '=', 'storage')] + def _get_storage_quantity(self, date=None): pool = Pool() Location = pool.get('stock.location') - locations = Location.search([ - ('type', '=', 'storage'), - ]) + locations = Location.search(self._domain_storage_quantity()) if not date: date = datetime.date.today() location_ids = [l.id for l in locations]