From c2dea83744a5f9414f1d5642ddbc3334910eceed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Nowak?= <luke@nexedi.com>
Date: Tue, 5 Jan 2010 10:31:49 +0000
Subject: [PATCH]  - fix condition for alarm not being configured in alarm
 table

Alarm can be recognised as replaceable in catalog in two cases:

 * if alarm_date from catalog is empty (existing case)
 * if alarm is not existing in catalog yet (case added by changing indentation)

Second case happens during first indexation.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31573 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/Alarm.py | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/product/ERP5/Document/Alarm.py b/product/ERP5/Document/Alarm.py
index 78678f121e..ca60739173 100644
--- a/product/ERP5/Document/Alarm.py
+++ b/product/ERP5/Document/Alarm.py
@@ -583,20 +583,21 @@ Alarm Tool Node: %s
       result_list = self.Alarm_zGetAlarmDate(uid=self.getUid())
       if len(result_list) == 1:
         alarm_date = result_list[0].alarm_date
-        # But if the catalog does not have a valid one, replace it
-        # with the start date.
-        if alarm_date is None or alarm_date < periodicity_start_date:
-          alarm_date = periodicity_start_date
-
-        # Check if it is valid.
-        periodicity_stop_date = self.getPeriodicityStopDate()
-        if periodicity_stop_date is not None \
-              and alarm_date >= periodicity_stop_date:
-          alarm_date = None
-        else:
-          # convert the date to the user provided timezone
-          alarm_zone = periodicity_start_date.timezone()
-          alarm_date = alarm_date.toZone(alarm_zone)
+      # But if the catalog does not have a valid one, replace it
+      # with the start date.
+      if alarm_date is None or alarm_date < periodicity_start_date:
+        alarm_date = periodicity_start_date
+
+      # Check if it is valid.
+      periodicity_stop_date = self.getPeriodicityStopDate()
+      if periodicity_stop_date is not None \
+            and alarm_date >= periodicity_stop_date:
+        alarm_date = None
+      else:
+        # convert the date to the user provided timezone
+        alarm_zone = periodicity_start_date.timezone()
+        alarm_date = alarm_date.toZone(alarm_zone)
+
     return alarm_date
 
   # XXX there seem to be something which wants to call setters against
-- 
2.30.9