From 0b963de8da5b5b1eb9d1908ed10efbc77e8d3a94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 7 Jul 2016 10:07:33 +0200 Subject: [PATCH] Lock table to check overlap issue5522 review26451002 --- forecast.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/forecast.py b/forecast.py index 7706ed6c8b..b77ae7365c 100644 --- a/forecast.py +++ b/forecast.py @@ -196,10 +196,13 @@ class Forecast(Workflow, ModelSQL, ModelView): forecast.check_date_overlap() def check_date_overlap(self): - cursor = Transaction().connection.cursor() if self.state != 'done': return + transaction = Transaction() + connection = transaction.connection + transaction.database.lock(connection, self._table) forcast = self.__table__() + cursor = connection.cursor() cursor.execute(*forcast.select(forcast.id, where=(((forcast.from_date <= self.from_date) & (forcast.to_date >= self.from_date))