diff --git a/product/ERP5/Tool/DomainTool.py b/product/ERP5/Tool/DomainTool.py index a8d33eb6275054fe210f6a9e10ee43598e2f9940..e397d6f4ada4f8d08b413b3ade3ecdad43297834 100644 --- a/product/ERP5/Tool/DomainTool.py +++ b/product/ERP5/Tool/DomainTool.py @@ -115,7 +115,7 @@ class DomainTool(BaseTool): if value is not None: # Handle Mysql datetime correctly if isinstance(value, DateTime): - value = value.ISO() + value = value.toZone('UTC').ISO() format_dict['value'] = value # Generate expression expression += "OR (%(base_name)s = '%(value)s') " \ diff --git a/product/ERP5/Tool/SimulationTool.py b/product/ERP5/Tool/SimulationTool.py index d6fc01f3c8d5241d503ce3d4909e1a1ebc1973f5..0252a0c7f836a60122af736c0e46f9e68ff83fe9 100644 --- a/product/ERP5/Tool/SimulationTool.py +++ b/product/ERP5/Tool/SimulationTool.py @@ -955,7 +955,7 @@ class SimulationTool(BaseTool): if len(date_value_list) > 0: date = min(date_value_list) if isinstance(date, DateTime): - date = date.ISO() + date = date.toZone('UTC').ISO() # build a query for date to take range into account date_query_kw = {"inventory.date" : date, "operator" : column_value_dict.get('date', {}).get('operator', []), diff --git a/product/ERP5/tests/testAlarm.py b/product/ERP5/tests/testAlarm.py index 35b29b4d755b2a83eb4a6df58f7873f410a93a13..e256c4eebf169ef86ef4383efc2a9c8aaa76432f 100644 --- a/product/ERP5/tests/testAlarm.py +++ b/product/ERP5/tests/testAlarm.py @@ -57,6 +57,8 @@ class TestAlarm(ERP5TypeTestCase): sales_order_id = '1' quantity = 10 base_price = 0.7832 + # year/month/day hour:minute:second + date_format = '%i/%i/%i %i:%i:%d UTC' def getTitle(self): return "Alarm" @@ -152,7 +154,7 @@ class TestAlarm(ERP5TypeTestCase): ZopeTestCase._print('\n%s ' % message) LOG('Testing... ',0,message) alarm = self.newAlarm() - now = DateTime() + now = DateTime().toZone('UTC') hour_to_remove = now.hour() % 3 now = addToDate(now,hour=-hour_to_remove) date = addToDate(now,day=2) @@ -179,12 +181,12 @@ class TestAlarm(ERP5TypeTestCase): message = 'Test Some Hours' ZopeTestCase._print('\n%s ' % message) LOG('Testing... ',0,message) - # year/month/day hour:minute:second - right_first_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,6,15,00,00)) - now = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,6,15,00,00)) - right_second_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,6,21,00,00)) - right_third_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,7,06,00,00)) - right_fourth_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,7,10,00,00)) + + right_first_date = DateTime(self.date_format % (2006,10,6,15,00,00)) + now = DateTime(self.date_format % (2006,10,6,15,00,00)) + right_second_date = DateTime(self.date_format % (2006,10,6,21,00,00)) + right_third_date = DateTime(self.date_format % (2006,10,7,06,00,00)) + right_fourth_date = DateTime(self.date_format % (2006,10,7,10,00,00)) alarm = self.newAlarm() hour_list = (6,10,15,21) alarm.setPeriodicityStartDate(now) @@ -205,11 +207,11 @@ class TestAlarm(ERP5TypeTestCase): message = 'Every Day Once' ZopeTestCase._print('\n%s ' % message) LOG('Testing... ',0,message) - # year/month/day hour:minute:second - now = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,6,10,00,00)) - right_first_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,6,10,00,00)) - right_second_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,7,10,00,00)) - right_third_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,8,10,00,00)) + + now = DateTime(self.date_format % (2006,10,6,10,00,00)) + right_first_date = DateTime(self.date_format % (2006,10,6,10,00,00)) + right_second_date = DateTime(self.date_format % (2006,10,7,10,00,00)) + right_third_date = DateTime(self.date_format % (2006,10,8,10,00,00)) alarm = self.newAlarm() alarm.setPeriodicityStartDate(now) alarm.setPeriodicityDayFrequency(1) @@ -229,11 +231,11 @@ class TestAlarm(ERP5TypeTestCase): message = 'Every 3 Days Some Hours' ZopeTestCase._print('\n%s ' % message) LOG('Testing... ',0,message) - # year/month/day hour:minute:second - right_first_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,6,14,00,00)) - right_second_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,6,15,00,00)) - right_third_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,6,17,00,00)) - right_fourth_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,9,14,00,00)) + + right_first_date = DateTime(self.date_format % (2006,10,6,14,00,00)) + right_second_date = DateTime(self.date_format % (2006,10,6,15,00,00)) + right_third_date = DateTime(self.date_format % (2006,10,6,17,00,00)) + right_fourth_date = DateTime(self.date_format % (2006,10,9,14,00,00)) alarm = self.newAlarm() alarm.setPeriodicityStartDate(right_first_date) alarm.setPeriodicityDayFrequency(3) @@ -255,11 +257,11 @@ class TestAlarm(ERP5TypeTestCase): message = 'Some Week Days Some Hours' ZopeTestCase._print('\n%s ' % message) LOG('Testing... ',0,message) - # year/month/day hour:minute:second - right_first_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,9,27,6,00,00)) - right_second_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,9,29,15,00,00)) - right_third_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,2,6,00,00)) - right_fourth_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,2,15,00,00)) + + right_first_date = DateTime(self.date_format % (2006,9,27,6,00,00)) + right_second_date = DateTime(self.date_format % (2006,9,29,15,00,00)) + right_third_date = DateTime(self.date_format % (2006,10,2,6,00,00)) + right_fourth_date = DateTime(self.date_format % (2006,10,2,15,00,00)) alarm = self.newAlarm() get_transaction().commit() self.tic() @@ -293,11 +295,11 @@ class TestAlarm(ERP5TypeTestCase): message = 'Some Month Days Some Hours' ZopeTestCase._print('\n%s ' % message) LOG('Testing... ',0,message) - # year/month/day hour:minute:second - right_first_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,01,12,00,00)) - right_second_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,01,14,00,00)) - right_third_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,15,12,00,00)) - right_fourth_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,15,14,00,00)) + + right_first_date = DateTime(self.date_format % (2006,10,01,12,00,00)) + right_second_date = DateTime(self.date_format % (2006,10,01,14,00,00)) + right_third_date = DateTime(self.date_format % (2006,10,15,12,00,00)) + right_fourth_date = DateTime(self.date_format % (2006,10,15,14,00,00)) alarm = self.newAlarm() alarm.setPeriodicityStartDate(right_first_date) alarm.setPeriodicityMonthDayList((1,15)) @@ -313,10 +315,10 @@ class TestAlarm(ERP5TypeTestCase): message = 'Once Every 2 Month' ZopeTestCase._print('\n%s ' % message) LOG('Testing... ',0,message) - # year/month/day hour:minute:second - right_first_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,01,6,00,00)) - right_second_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,12,01,6,00,00)) - right_third_date = DateTime('%i/%i/%i %i:%i:%d' % (2007,2,01,6,00,00)) + + right_first_date = DateTime(self.date_format % (2006,10,01,6,00,00)) + right_second_date = DateTime(self.date_format % (2006,12,01,6,00,00)) + right_third_date = DateTime(self.date_format % (2007,2,01,6,00,00)) alarm = self.newAlarm() alarm.setPeriodicityStartDate(right_first_date) alarm.setPeriodicityMonthDayList((1,)) @@ -332,11 +334,11 @@ class TestAlarm(ERP5TypeTestCase): message = 'Every Day Once Week 41 And 43' ZopeTestCase._print('\n%s ' % message) LOG('Testing... ',0,message) - # year/month/day hour:minute:second - right_first_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,1,6,00,00)) - right_second_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,9,6,00,00)) - right_third_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,10,6,00,00)) - right_fourth_date = DateTime('%i/%i/%i %i:%i:%d' % (2006,10,11,6,00,00)) + + right_first_date = DateTime(self.date_format % (2006,10,1,6,00,00)) + right_second_date = DateTime(self.date_format % (2006,10,9,6,00,00)) + right_third_date = DateTime(self.date_format % (2006,10,10,6,00,00)) + right_fourth_date = DateTime(self.date_format % (2006,10,11,6,00,00)) alarm = self.newAlarm() alarm.setPeriodicityStartDate(right_first_date) alarm.setPeriodicityHourList((6,)) diff --git a/product/ERP5/tests/testInventoryAPI.py b/product/ERP5/tests/testInventoryAPI.py index 19c82dd5c321117dc694f707a9602812e3f7269c..0895b384111d322dd1bd4862aa5036a63e7395b7 100644 --- a/product/ERP5/tests/testInventoryAPI.py +++ b/product/ERP5/tests/testInventoryAPI.py @@ -715,9 +715,9 @@ class TestInventoryList(InventoryAPITestCase): def test_GroupByDate(self): # group by date currently only groups by *exact* date getInventoryList = self.getSimulationTool().getInventoryList - self._makeMovement(quantity=1, start_date=DateTime(2000, 1, 1)) - self._makeMovement(quantity=1, start_date=DateTime(2000, 1, 1)) - self._makeMovement(quantity=1, start_date=DateTime(2001, 1, 1)) + self._makeMovement(quantity=1, start_date=DateTime('2000/1/1 12:00 UTC')) + self._makeMovement(quantity=1, start_date=DateTime('2000/1/1 12:00 UTC')) + self._makeMovement(quantity=1, start_date=DateTime('2001/1/1 12:00 UTC')) inventory_list = getInventoryList(node_uid=self.node.getUid(), group_by_date=1) self.assertEquals(2, len(inventory_list))