Commit 5e43bd5b authored by Sebastien Robin's avatar Sebastien Robin

erp5_core: make simulation_tool.getMovementHistoryList returning mirror_dates

This is useful to get both start and stop dates of movements without the need of
getting directly objects.
parent a5e3bc8b
...@@ -284,10 +284,14 @@ class TrackingListBrain(InventoryListBrain): ...@@ -284,10 +284,14 @@ class TrackingListBrain(InventoryListBrain):
class MovementHistoryListBrain(InventoryListBrain): class MovementHistoryListBrain(InventoryListBrain):
"""Brain for getMovementHistoryList """Brain for getMovementHistoryList
""" """
def _date(self):
def _convertDateToZone(self, date_utc):
# Convert the date in the movement's original timezone. # Convert the date in the movement's original timezone.
# ZSQL method selects date as date_, and here we find the object to get the # ZSQL method selects date as date_utc or mirror_date_utc, and here we find
# timezone and convert the date to this timezone # the object to get the timezone and convert the date to this timezone
# It could be better to index the timezone in SQL table so that we do
# need to retrieve object all the time
date = date_utc
obj = self.getObject() obj = self.getObject()
if obj is not None: if obj is not None:
timezone = None timezone = None
...@@ -300,8 +304,15 @@ class MovementHistoryListBrain(InventoryListBrain): ...@@ -300,8 +304,15 @@ class MovementHistoryListBrain(InventoryListBrain):
if stop_date is not None: if stop_date is not None:
timezone = stop_date.timezone() timezone = stop_date.timezone()
if timezone is not None: if timezone is not None:
return self.date_utc.toZone(timezone) date = date_utc.toZone(timezone)
return self.date_utc return date
def _mirror_date(self):
return self._convertDateToZone(self.mirror_date_utc)
mirror_date = ComputedAttribute(_mirror_date, 1)
def _date(self):
return self._convertDateToZone(self.date_utc)
date = ComputedAttribute(_date, 1) date = ComputedAttribute(_date, 1)
def getListItemUrl(self, cname_id, selection_index, selection_name): def getListItemUrl(self, cname_id, selection_index, selection_name):
......
...@@ -6,6 +6,12 @@ ...@@ -6,6 +6,12 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>InventoryBrain</string> </value> <value> <string>InventoryBrain</string> </value>
...@@ -49,13 +55,28 @@ ...@@ -49,13 +55,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -68,7 +89,7 @@ ...@@ -68,7 +89,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -77,7 +98,7 @@ ...@@ -77,7 +98,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle> </pickle>
...@@ -90,33 +111,6 @@ ...@@ -90,33 +111,6 @@
<key> <string>action</string> </key> <key> <string>action</string> </key>
<value> <string>validate</string> </value> <value> <string>validate</string> </value>
</item> </item>
<item>
<key> <string>actor</string> </key>
<value> <string>ERP5TypeTestCase</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1384253447.9</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
</value>
</item>
<item> <item>
<key> <string>validation_state</string> </key> <key> <string>validation_state</string> </key>
<value> <string>validated</string> </value> <value> <string>validated</string> </value>
......
...@@ -490,6 +490,7 @@ SELECT\n ...@@ -490,6 +490,7 @@ SELECT\n
catalog.uid as uid,\n catalog.uid as uid,\n
catalog.relative_url as relative_url,\n catalog.relative_url as relative_url,\n
stock.date AS date_utc,\n stock.date AS date_utc,\n
stock.mirror_date AS mirror_date_utc,\n
<dtml-if expr="precision is not None">\n <dtml-if expr="precision is not None">\n
<dtml-if group_by_expression>SUM</dtml-if>(ROUND(stock.quantity, <dtml-var precision>)) AS total_quantity,\n <dtml-if group_by_expression>SUM</dtml-if>(ROUND(stock.quantity, <dtml-var precision>)) AS total_quantity,\n
<dtml-if group_by_expression>SUM</dtml-if>(ROUND(stock.total_price, <dtml-var precision>)) AS total_price,\n <dtml-if group_by_expression>SUM</dtml-if>(ROUND(stock.total_price, <dtml-var precision>)) AS total_price,\n
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment