Commit db890976 authored by Klaus Wölfel's avatar Klaus Wölfel Committed by Klaus Wölfel

erp5_trade: Order Report improvements

- Optionally group by function
- Give higher priority to Order Report compared to Workflow Report
- Optionally filter by Quantity Unit and enable Stat Columns for Quantity

TODO: Quantity also for Thirs Party if filtered by quantity Unit
parent d1167cb8
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>8.0</float> </value>
<value> <float>12.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
......
......@@ -61,6 +61,7 @@ aggregation_level = request.get(\'aggregation_level\')\n
from_date = request.get(\'from_date\')\n
to_date = request.get(\'at_date\')\n
group_by = request.get(\'group_by\')\n
quantity_unit = request.get(\'quantity_unit\')\n
simulation_state = request.get(\'simulation_state\', ())\n
\n
# define some parameter dependings on module\n
......@@ -126,12 +127,17 @@ else:\n
if group_by == "product":\n
selection_columns = [(\'product\', "Product")]\n
stat_columns = [(\'product\', "product")]\n
elif group_by == "function":\n
function_title = context.AccountingTransactionLine_getFunctionBaseCategoryTitle()\n
selection_columns = [(\'product\', function_title)]\n
stat_columns = [(\'product\', "product")]\n
else:\n
selection_columns = [(\'client\', "Client"), (\'product\', "Product")]\n
stat_columns = [(\'client\', "client"), (\'product\', "product")]\n
for x in interval_list:\n
interval_column_list.extend([("Amount %s" %x,"Amount %s" %x), ("Quantity %s" %x,"Quantity %s" %x),\n
("Quantity Unit %s" %x,"Quantity Unit %s" %x)])\n
interval_column_list.extend([("Amount %s" %x,"Amount %s" %x), ("Quantity %s" %x,"Quantity %s" %x)])\n
if not quantity_unit:\n
interval_column_list.extend([("Quantity Unit %s" %x,"Quantity Unit %s" %x)])\n
total_column_list = [(\'total amount\', \'Total Amount\'),(\'total quantity\', \'Total Quantity\')]\n
total_stat_list = [(\'total amount\', \'total amount\'),(\'total quantity\', \'total quantity\')]\n
\n
......
......@@ -63,6 +63,7 @@ from_date = request.get(\'from_date\', None)\n
to_date = request.get(\'at_date\', None)\n
aggregation_level = request.get(\'aggregation_level\', None)\n
report_group_by = request.get(\'group_by\', None)\n
quantity_unit = request.get(\'quantity_unit\', None)\n
# get all category\n
incoterm = request.get(\'incoterm\', None)\n
section_category = request.get(\'section_category\', None)\n
......@@ -163,8 +164,18 @@ for result in result_list:\n
# client_title -> product_title -> period -> amount/quantity...\n
# or product_title -> period -> amount/quantity...\n
for line in result.contentValues(filter = {\'portal_type\':line_portal_type}):\n
# Filter by quantity_unit\n
if quantity_unit:\n
if line.getQuantityUnit() != quantity_unit:\n
continue\n
# FIXME: if two resources have the same title, do we want to group ?\n
product_title = line.getResourceTitle()\n
if report_group_by == "function":\n
if report_type == "sale":\n
product_title = line.getSourceFunctionTitle()\n
else:\n
product_title = line.getDestinationFunctionTitle()\n
else:\n
product_title = line.getResourceTitle()\n
if not line_dict.has_key(product_title):\n
line_dict[product_title] = {period :{"amount" : line.getTotalPrice(),\n
"quantity" : line.getTotalQuantity(),\n
......@@ -239,6 +250,12 @@ if len(client_dict):\n
line_product_dict[product_title][period][\'amount\']\n
else:\n
period_counter_dict[\'Amount %s\' %(period)] = line_product_dict[product_title][period][\'amount\']\n
if quantity_unit:\n
if period_counter_dict.has_key(\'Quantity %s\' %(period)):\n
period_counter_dict[\'Quantity %s\' %(period)] = period_counter_dict[\'Quantity %s\' %(period)] + \\\n
line_product_dict[product_title][period][\'quantity\']\n
else:\n
period_counter_dict[\'Quantity %s\' %(period)] = line_product_dict[product_title][period][\'quantity\']\n
\n
else:\n
obj[\'Amount %s\' %(period)] = 0\n
......@@ -252,6 +269,11 @@ if len(client_dict):\n
period_counter_dict[\'total amount\'] = period_counter_dict[\'total amount\'] + line_total_amount\n
else:\n
period_counter_dict[\'total amount\'] = line_total_amount\n
if quantity_unit:\n
if period_counter_dict.has_key(\'total quantity\'):\n
period_counter_dict[\'total quantity\'] = period_counter_dict[\'total quantity\'] + line_total_quantity\n
else:\n
period_counter_dict[\'total quantity\'] = line_total_quantity\n
\n
product_lines_list.append(obj)\n
# sort product list\n
......@@ -259,7 +281,7 @@ if len(client_dict):\n
extend(product_lines_list)\n
else:\n
# products\n
if report_group_by == "product":\n
if report_group_by in ("product", "function"):\n
for product_title in product_dict.keys():\n
obj = Object(uid="new_")\n
obj[\'product\'] = product_title\n
......@@ -278,6 +300,11 @@ else:\n
period_counter_dict[\'Amount %s\' %(period)] = period_counter_dict[\'Amount %s\' %(period)] + product_dict[product_title][period][\'amount\']\n
else:\n
period_counter_dict[\'Amount %s\' %(period)] = product_dict[product_title][period][\'amount\']\n
if quantity_unit:\n
if period_counter_dict.has_key(\'Quantity %s\' %(period)):\n
period_counter_dict[\'Quantity %s\' %(period)] = period_counter_dict[\'Quantity %s\' %(period)] + product_dict[product_title][period][\'quantity\']\n
else:\n
period_counter_dict[\'Quantity %s\' %(period)] = product_dict[product_title][period][\'quantity\']\n
else:\n
obj[\'Amount %s\' %(period)] = 0\n
obj[\'Quantity %s\' %(period)] = 0\n
......@@ -290,6 +317,11 @@ else:\n
period_counter_dict[\'total amount\'] = period_counter_dict[\'total amount\'] + line_total_amount\n
else:\n
period_counter_dict[\'total amount\'] = line_total_amount\n
if quantity_unit:\n
if period_counter_dict.has_key(\'total quantity\'):\n
period_counter_dict[\'total quantity\'] = period_counter_dict[\'total quantity\'] + line_total_quantity\n
else:\n
period_counter_dict[\'total quantity\'] = line_total_quantity\n
append(obj)\n
\n
line_list.sort(sortProduct)\n
......
......@@ -2,7 +2,7 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5Form" module="Products.ERP5Form.Form"/>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
......@@ -94,6 +94,7 @@
<string>your_delivery_mode</string>
<string>your_from_date</string>
<string>your_group_by</string>
<string>your_quantity_unit</string>
<string>your_incoterm</string>
<string>your_order</string>
<string>your_section_category</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_quantity_unit</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_dialog_mode_category</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Quantity Unit</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -2,7 +2,7 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5Form" module="Products.ERP5Form.Form"/>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
......@@ -114,6 +114,7 @@
<list>
<string>your_aggregation_level</string>
<string>your_group_by</string>
<string>your_quantity_unit</string>
<string>your_simulation_state</string>
</list>
</value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_quantity_unit</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_dialog_mode_category</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Quantity Unit</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -2,7 +2,7 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5Form" module="Products.ERP5Form.Form"/>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
......
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