[Erp5-report] r22717 - /erp5/trunk/products/ERP5/Extensions/InventoryBrain.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Jul 29 14:35:02 CEST 2008


Author: nicolas
Date: Tue Jul 29 14:35:01 2008
New Revision: 22717

URL: http://svn.erp5.org?rev=22717&view=rev
Log:
Add new Brain for Tracking list which convert date to current timezone

Modified:
    erp5/trunk/products/ERP5/Extensions/InventoryBrain.py

Modified: erp5/trunk/products/ERP5/Extensions/InventoryBrain.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Extensions/InventoryBrain.py?rev=22717&r1=22716&r2=22717&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Extensions/InventoryBrain.py (original)
+++ erp5/trunk/products/ERP5/Extensions/InventoryBrain.py Tue Jul 29 14:35:01 2008
@@ -286,6 +286,26 @@
                     mapping = mapping )
     return N_('Unknown')
 
+class TrackingListBrain(InventoryListBrain):
+  """
+  List of aggregated movements
+  """
+  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:
+      movement_list = obj.getAggregateRelatedValueList()
+      for movement in movement_list:
+        date = movement.getStartDate() or movement.getStopDate()
+        if date is not None:
+          timezone = date.timezone()
+          self.date = self.date.toZone(timezone)
+          break
+
 class DeliveryListBrain(InventoryListBrain):
   """
     Lists each variation




More information about the Erp5-report mailing list