[Erp5-report] r18666 - in /erp5/trunk/products/ERP5: Extensions/ bootstrap/erp5_core/SkinTe...
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Jan 11 16:16:16 CET 2008
Author: jerome
Date: Fri Jan 11 16:16:15 2008
New Revision: 18666
URL: http://svn.erp5.org?rev=18666&view=rev
Log:
Since we store movement dates converted in UTC, 'date' attribute on brains
returned by getMovementHistoryList were returned as UTC.
This patch convert dates to the original timezone.
Modified:
erp5/trunk/products/ERP5/Extensions/InventoryBrain.py
erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.xml
erp5/trunk/products/ERP5/tests/testInventoryAPI.py
Modified: erp5/trunk/products/ERP5/Extensions/InventoryBrain.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Extensions/InventoryBrain.py?rev=18666&r1=18665&r2=18666&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Extensions/InventoryBrain.py (original)
+++ erp5/trunk/products/ERP5/Extensions/InventoryBrain.py Fri Jan 11 16:16:15 2008
@@ -342,3 +342,22 @@
list(self.getPortalFutureInventoryStateList()) + \
list(self.getPortalReservedInventoryStateList()) + \
list(self.getPortalCurrentInventoryStateList()))
+
+
+class MovementHistoryListBrain(InventoryListBrain):
+ """Brain for getMovementHistoryList
+ """
+ def __init__(self):
+ if not self.date:
+ return
+ # convert the date in the movement's original timezone.
+ # This is a somehow heavy operation, but fortunatly it's only called when
+ # the brain is accessed from the Shared.DC.ZRDB.Results.Results instance
+ obj = self.getObject()
+ if obj is not None:
+ if self.node_relative_url == obj.getSource():
+ timezone = obj.getStartDate().timezone()
+ else:
+ timezone = obj.getStopDate().timezone()
+ self.date = self.date.toZone(timezone)
+
Modified: erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.xml?rev=18666&r1=18665&r2=18666&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.xml (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.xml Fri Jan 11 16:16:15 2008
@@ -626,7 +626,7 @@
</item>
<item>
<key> <string>class_name_</string> </key>
- <value> <string>InventoryListBrain</string> </value>
+ <value> <string>MovementHistoryListBrain</string> </value>
</item>
<item>
<key> <string>connection_hook</string> </key>
Modified: erp5/trunk/products/ERP5/tests/testInventoryAPI.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testInventoryAPI.py?rev=18666&r1=18665&r2=18666&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testInventoryAPI.py (original)
+++ erp5/trunk/products/ERP5/tests/testInventoryAPI.py Fri Jan 11 16:16:15 2008
@@ -842,7 +842,7 @@
# maybe this check is too low level (Shared/DC/ZRDB//Results.py, class r)
r_bases = getMovementHistoryList()._class.__bases__
brain_class = r_bases[2].__name__
- self.assertEquals('InventoryListBrain', brain_class,
+ self.assertEquals('MovementHistoryListBrain', brain_class,
"unexpected brain class for getMovementHistoryList InventoryListBrain"
" != %s (bases %s)" % (brain_class, r_bases))
@@ -1103,6 +1103,39 @@
from_date=DateTime(2006, 01, 02),
to_date=DateTime(2006, 01, 03),
section_uid=self.mirror_section.getUid())), 1)
+
+
+ def test_BrainDateTimeZone(self):
+ getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
+ self._makeMovement(quantity=100,
+ start_date=DateTime('2001/02/03 04:05 GMT+3'))
+ movement_history_list = getMovementHistoryList(
+ section_uid=self.section.getUid())
+ self.assertEquals(len(movement_history_list), 1)
+ brain = movement_history_list[0]
+ self.assertEquals(DateTime('2001/02/03 04:05 GMT+3'), brain.date)
+ self.assertEquals('GMT+3', brain.date.timezone())
+
+ def test_BrainDateTimeZoneStopDate(self):
+ getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
+ self._makeMovement(quantity=100,
+ start_date=DateTime('2001/02/03 04:05 GMT+2'),
+ stop_date=DateTime('2001/02/03 04:05 GMT+3'))
+ movement_history_list = getMovementHistoryList(
+ mirror_section_uid=self.section.getUid())
+ self.assertEquals(len(movement_history_list), 1)
+ brain = movement_history_list[0]
+ self.assertEquals(DateTime('2001/02/03 04:05 GMT+2'), brain.date)
+ self.assertEquals('GMT+2', brain.date.timezone())
+
+ def test_BrainEmptyDate(self):
+ getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
+ self._makeMovement(quantity=100,)
+ movement_history_list = getMovementHistoryList(
+ section_uid=self.section.getUid())
+ self.assertEquals(len(movement_history_list), 1)
+ brain = movement_history_list[0]
+ self.assertEquals(None, brain.date)
def test_SortOnDate(self):
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
More information about the Erp5-report
mailing list