Commit 63f68940 authored by Arnaud Fontaine's avatar Arnaud Fontaine

KR Inventory Cache will be enabled gradually to avoid regressions.

So, do not modify getInventoryList(), at least for now.
parent c9b37715
...@@ -1300,16 +1300,9 @@ class SimulationTool(BaseTool): ...@@ -1300,16 +1300,9 @@ class SimulationTool(BaseTool):
'convert_quantity_result': convert_quantity_result, 'convert_quantity_result': convert_quantity_result,
'quantity_unit_uid': quantity_unit_uid, 'quantity_unit_uid': quantity_unit_uid,
} }
# Get cached data
# Use Custom Inventory Cache implementation if any, before falling back if getattr(self, "Resource_zGetInventoryCacheResult", None) is not None and \
# on ERP5 Generic Cache implementation optimisation__ and (not kw.get('from_date')) and \
cached_result = []
if optimisation__ and \
not getattr(self, 'SimulationTool_getInventoryCustomCache', None)(kw,
base_inventory_kw,
cached_result) and \
getattr(self, "Resource_zGetInventoryCacheResult", None) is not None and \
(not kw.get('from_date')) and \
'transformed_resource' not in kw: 'transformed_resource' not in kw:
# Here is the different kind of date # Here is the different kind of date
# from_date : >= # from_date : >=
...@@ -1330,6 +1323,7 @@ class SimulationTool(BaseTool): ...@@ -1330,6 +1323,7 @@ class SimulationTool(BaseTool):
sql_kw=kw, sql_kw=kw,
**base_inventory_kw) **base_inventory_kw)
except StockOptimisationError: except StockOptimisationError:
cached_result = []
kw['to_date'] = to_date kw['to_date'] = to_date
else: else:
if src__: if src__:
...@@ -1337,6 +1331,8 @@ class SimulationTool(BaseTool): ...@@ -1337,6 +1331,8 @@ class SimulationTool(BaseTool):
# Now must generate query for date diff # Now must generate query for date diff
kw['to_date'] = to_date kw['to_date'] = to_date
kw['from_date'] = cached_date kw['from_date'] = cached_date
else:
cached_result = []
sql_kw, new_kw = self._generateKeywordDict(**kw) sql_kw, new_kw = self._generateKeywordDict(**kw)
# Copy kw content as _generateSQLKeywordDictFromKeywordDict # Copy kw content as _generateSQLKeywordDictFromKeywordDict
# remove some values from it # remove some values from it
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment