Commit 38f68c1f authored by Jérome Perrin's avatar Jérome Perrin

rewrite InventoryLine/Cell.getTotalInventory to get rid of InventoryLine_zGetTotal

parent bd44aa55
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="SQL" module="Products.ZSQLMethods.SQL"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>allow_simple_one_argument_traversal</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string>uid</string> </value>
</item>
<item>
<key> <string>cache_time_</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>class_file_</string> </key>
<value> <string>ZSQLCatalog.zsqlbrain</string> </value>
</item>
<item>
<key> <string>class_name_</string> </key>
<value> <string>ZSQLBrain</string> </value>
</item>
<item>
<key> <string>connection_hook</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_sql_connection</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>InventoryLine_zGetTotal</string> </value>
</item>
<item>
<key> <string>max_cache_</string> </key>
<value> <int>100</int> </value>
</item>
<item>
<key> <string>max_rows_</string> </key>
<value> <int>1000</int> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string encoding="cdata"><![CDATA[
SELECT \n
\tSUM(inventory) AS total_inventory, \n
\tSUM(inventory * price) AS total_price, \n
\tAVG(price) AS average_price\n
FROM\n
catalog, movement\n
WHERE \n
\tcatalog.parent_uid = <dtml-sqlvar uid type="int">\n
AND\t\n
\tcatalog.uid = movement.uid\n
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -66,14 +66,9 @@ class InventoryCell(DeliveryCell): ...@@ -66,14 +66,9 @@ class InventoryCell(DeliveryCell):
security.declareProtected(Permissions.AccessContentsInformation, 'getTotalInventory') security.declareProtected(Permissions.AccessContentsInformation, 'getTotalInventory')
def getTotalInventory(self): def getTotalInventory(self):
""" """
Returns the inventory if no cell or the total inventory if cells Returns the inventory, as cells are not supposed to contain more cells.
""" """
if not self.hasCellContent(): return self.getInventory()
return self.getInventory()
else:
# Use MySQL
aggregate = self.InventoryLine_zGetTotal()[0]
return aggregate.total_inventory or 0.0
security.declareProtected(Permissions.AccessContentsInformation, 'getQuantity') security.declareProtected(Permissions.AccessContentsInformation, 'getQuantity')
def getQuantity(self): def getQuantity(self):
......
...@@ -70,13 +70,6 @@ class InventoryLine(DeliveryLine): ...@@ -70,13 +70,6 @@ class InventoryLine(DeliveryLine):
if not self.hasCellContent(): if not self.hasCellContent():
return self.getInventory() return self.getInventory()
else: else:
# Use MySQL
# There is no inventory column in mysql any more,
# is it required to add it again. It is only
# usefull for the user interface
# aggregate = self.InventoryLine_zGetTotal()[0]
# return aggregate.total_inventory or 0.0
total_quantity = 0.0 total_quantity = 0.0
for cell in self.getCellValueList(base_id='movement'): for cell in self.getCellValueList(base_id='movement'):
if cell.getInventory() is not None: if cell.getInventory() is not None:
......
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