Commit 71b00753 authored by Sebastien Robin's avatar Sebastien Robin

stock cache: avoid possibly random errors

ProgrammingError could be raised for various raisons, while the code
was assuming that the only raison was missing table. Improve by making
sure the error is about missing table, if not, raise.
parent fa128ff7
......@@ -52,6 +52,7 @@ from Shared.DC.ZRDB.Results import Results
from Products.ERP5Type.Utils import mergeZRDBResults
from App.Extensions import getBrain
from MySQLdb import ProgrammingError
from MySQLdb.constants.ER import NO_SUCH_TABLE
from hashlib import md5
from warnings import warn
......@@ -1404,7 +1405,9 @@ class SimulationTool(BaseTool):
inventory_cache_kw['date'] = to_date
cached_sql_result = Resource_zGetInventoryCacheResult(**inventory_cache_kw)
except ProgrammingError:
except ProgrammingError, (code, _):
if code != NO_SUCH_TABLE:
# First use of the optimisation, we need to create the table
LOG("SimulationTool._getCachedInventoryList", INFO,
"Creating inventory cache stock")
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