Commit 479e7501 authored by Sebastien Robin's avatar Sebastien Robin

2008-09-12 Seb

* Added per month per worker quantity summary
* added simulation state dialog parameter
* added from_date dialog parameter
* added at_date dialog parameter

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23590 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 515245dd
......@@ -117,9 +117,6 @@ else:\n
object_url_dict[\'/\'.join(splitted_object_url[0:x+1])] = 1\n
for parent_category in parent_category_list:\n
parent_category = \'/\'.join(parent_category.split(\'/\')[1:])\n
context.log(\'string_index\', getattr(parent, \'string_index\'))\n
context.log(\'parent_category\', parent_category)\n
context.log(\'object_sub_dict\', object_sub_dict)\n
if object_url_dict.has_key(parent_category):\n
category_child_list = context.restrictedTraverse(parent_category).contentValues(portal_type=project_line_portal_type)\n
for category_child in category_child_list:\n
......@@ -132,15 +129,17 @@ for category in category_list:\n
string_index = getattr(category, \'string_index\', None)\n
if string_index is None:\n
string_index = getattr(parent, \'string_index\')\n
domain_kw = {}\n
if depth >= 1:\n
domain_kw[\'membership_criterion_base_category\'] = (\'source_project\', )\n
domain_kw[\'membership_criterion_category\'] = (\'source_project/\' + category.getRelativeUrl(),)\n
domain = parent.generateTempDomain(id = \'%s_%s\' % (depth, i))\n
domain.edit(title = category.getTitle(),\n
domain_generator_method_id = script.id,\n
criterion_property_list = [\'string_index\'] ,\n
string_index = string_index,\n
membership_criterion_base_category = (\'source_project\', ),\n
membership_criterion_category = (\'source_project/\' + category.getRelativeUrl(),),\n
domain_generator_method_id = script.id,\n
uid = category.getUid())\n
uid = category.getUid(),\n
**domain_kw)\n
domain.setCriterion(\'string_index\', identity=string_index)\n
domain_list.append(domain)\n
i += 1\n
......@@ -229,7 +228,9 @@ return domain_list\n
<string>category_child</string>
<string>category</string>
<string>string_index</string>
<string>domain_kw</string>
<string>domain</string>
<string>_apply_</string>
<string>script</string>
</tuple>
</value>
......
......@@ -9,22 +9,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......@@ -70,16 +58,25 @@
\n
object_domain = selection_report.asDomainItemDict()[\'project_report_monthly_domain\']\n
object_dict = context.object_dict\n
summary_dict = context.summary_dict\n
\n
context.log(\'object_domain.showDict\', object_domain.showDict())\n
current_criterion = object_domain.getCriterionList()\n
date = current_criterion[0].identity\n
returned_object = object_dict.get(date,None)\n
result_list = []\n
if returned_object is not None:\n
for k,v in returned_object.items():\n
if object_domain.test(v, strict_membership=1):\n
result_list.append(v)\n
if len(object_domain.getMembershipCriterionBaseCategoryList())==0:\n
# First level, so level of month\n
returned_object = summary_dict.get(date, None)\n
if returned_object is not None:\n
result_list.append(returned_object)\n
else:\n
returned_object = object_dict.get(date, None)\n
if returned_object is not None:\n
for k,v in returned_object.items():\n
if object_domain.test(v, strict_membership=1):\n
result_list.append(v)\n
\n
context.log(\'result_list\', [x.showDict() for x in result_list])\n
return result_list\n
</string> </value>
</item>
......@@ -89,18 +86,6 @@ return result_list\n
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>selection_report=None, selection=None, selection_domain=None, report_url=None, **kw</string> </value>
......@@ -139,14 +124,19 @@ return result_list\n
<string>object_domain</string>
<string>context</string>
<string>object_dict</string>
<string>summary_dict</string>
<string>current_criterion</string>
<string>date</string>
<string>result_list</string>
<string>len</string>
<string>None</string>
<string>returned_object</string>
<string>result_list</string>
<string>_getiter_</string>
<string>k</string>
<string>v</string>
<string>append</string>
<string>$append0</string>
<string>x</string>
</tuple>
</value>
</item>
......@@ -170,12 +160,6 @@ return result_list\n
<key> <string>id</string> </key>
<value> <string>Project_getMonthlyObjectList</string> </value>
</item>
<item>
<key> <string>uid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
......
......@@ -9,22 +9,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......@@ -67,6 +55,7 @@
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
from Products.ZSQLCatalog.SQLCatalog import Query\n
request = context.REQUEST\n
start_date = context.getStartDate()\n
stop_date = context.getStopDate()\n
......@@ -80,6 +69,17 @@ worker_column_list = []\n
source_project_uid_list = [x.uid for x in context.portal_catalog(\n
relative_url=\'%s%%\' % context.getRelativeUrl())]\n
\n
\n
sql_kw = {}\n
if kw.has_key(\'from_date\') and kw[\'from_date\'] is not None:\n
query_kw = {\'delivery.start_date\' : kw[\'from_date\'],\n
\'range\' : \'min\'}\n
sql_kw[\'delivery.start_date\'] = Query(**query_kw)\n
if kw.has_key(\'at_date\') and kw[\'at_date\'] is not None:\n
query_kw = {\'delivery.stop_date\' : kw[\'at_date\'],\n
\'range\' : \'ngt\'}\n
sql_kw[\'delivery.stop_date\'] = Query(**query_kw)\n
\n
# Make sure to not include "confirmed tasks" in any case, because in\n
# this case we must take task reports\n
if kw.has_key(\'simulation_state\') and len(kw[\'simulation_state\']) > 0 :\n
......@@ -95,18 +95,20 @@ task_list = [x.getObject() for x in \\\n
portal_type=\'Task\',\n
source_project_uid = source_project_uid_list,\n
simulation_state = task_simulation_state,\n
)]\n
**sql_kw)]\n
task_list.extend([x.getObject() for x in \\\n
context.portal_catalog(\n
portal_type=\'Task Report\',\n
source_project_uid = source_project_uid_list,\n
simulation_state = task_report_simulation_state,\n
)])\n
**sql_kw)])\n
\n
task_line_list = []\n
for task in task_list:\n
task_line_list.extend(task.objectValues(portal_type=(\'Task Line\', \'Task Report Line\')))\n
\n
monthly_worker_quantity_dict = {} # Used to get quantity per month and per worker\n
\n
\n
for task_line in task_line_list:\n
# initialize some variables\n
......@@ -146,23 +148,37 @@ for task_line in task_line_list:\n
timekeeper = start_date_task\n
while timekeeper <= stop_date_task :\n
next_timekeeper = getNextMonthStart(timekeeper)\n
quantity_dict = object_dict.setdefault("%s-%s" % ( timekeeper.year(), timekeeper.month()), {})\n
string_index = "%s-%s" % ( timekeeper.year(), timekeeper.month())\n
quantity_dict = object_dict.setdefault(string_index, {})\n
\n
worker_quantity_dict = monthly_worker_quantity_dict.setdefault(string_index, {})\n
\n
if not quantity_dict.has_key(project_relative_url):\n
temp_object = context.newContent(portal_type = \'Project Line\',\n
temp_object=1,\n
string_index = "%s-%s" % (timekeeper.year() , timekeeper.month()),\n
string_index = string_index,\n
category_list = [\'source_project/%s\' % project_relative_url])\n
quantity_dict[project_relative_url] = temp_object\n
current_temp_object = quantity_dict[project_relative_url]\n
current_month_quantity = (min(next_timekeeper,stop_date_task+1) - timekeeper )/ diff_day * quantity\n
\n
object_quantity = current_month_quantity + current_temp_object.getProperty(source, 0)\n
worker_quantity_dict[source] = worker_quantity_dict.get(source, 0) + current_month_quantity\n
current_temp_object.setProperty(source, object_quantity)\n
timekeeper = next_timekeeper\n
\n
# Now build temp objects for quantity per month and per worker\n
summary_dict = {}\n
for string_index, worker_quantity_dict in monthly_worker_quantity_dict.items():\n
temp_object = context.newContent(portal_type = \'Project Line\',\n
temp_object=1,\n
string_index = string_index)\n
summary_dict[string_index] = temp_object\n
for source, quantity in worker_quantity_dict.items():\n
temp_object.setProperty(source, quantity)\n
\n
column_list.extend(worker_column_list)\n
context = context.asContext(object_dict = object_dict,\n
summary_dict = summary_dict,\n
column_list = column_list,)\n
\n
selection_name = \'project_monthly_report_selection\'\n
......@@ -179,12 +195,6 @@ return context.Project_viewODSMonthlyReport()\n
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
......@@ -214,6 +224,8 @@ return context.Project_viewODSMonthlyReport()\n
<value>
<tuple>
<string>kw</string>
<string>Products.ZSQLCatalog.SQLCatalog</string>
<string>Query</string>
<string>_getattr_</string>
<string>context</string>
<string>request</string>
......@@ -227,14 +239,19 @@ return context.Project_viewODSMonthlyReport()\n
<string>_getiter_</string>
<string>x</string>
<string>source_project_uid_list</string>
<string>len</string>
<string>sql_kw</string>
<string>_getitem_</string>
<string>None</string>
<string>query_kw</string>
<string>_apply_</string>
<string>_write_</string>
<string>len</string>
<string>task_simulation_state</string>
<string>task_report_simulation_state</string>
<string>None</string>
<string>task_list</string>
<string>task_line_list</string>
<string>task</string>
<string>monthly_worker_quantity_dict</string>
<string>task_line</string>
<string>source</string>
<string>source_title</string>
......@@ -244,7 +261,6 @@ return context.Project_viewODSMonthlyReport()\n
<string>month_start_date</string>
<string>date_string</string>
<string>current_date</string>
<string>_write_</string>
<string>_inplacevar_</string>
<string>current_column</string>
<string>project</string>
......@@ -254,12 +270,15 @@ return context.Project_viewODSMonthlyReport()\n
<string>getNextMonthStart</string>
<string>timekeeper</string>
<string>next_timekeeper</string>
<string>string_index</string>
<string>quantity_dict</string>
<string>worker_quantity_dict</string>
<string>temp_object</string>
<string>current_temp_object</string>
<string>min</string>
<string>current_month_quantity</string>
<string>object_quantity</string>
<string>summary_dict</string>
<string>selection_name</string>
</tuple>
</value>
......@@ -279,12 +298,6 @@ return context.Project_viewODSMonthlyReport()\n
<key> <string>id</string> </key>
<value> <string>Project_printAsODSMonthly</string> </value>
</item>
<item>
<key> <string>uid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
......
......@@ -9,12 +9,6 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......@@ -81,7 +75,7 @@
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<key> <string>bottom</string> </key>
<value>
<list>
<string>listbox</string>
......@@ -89,25 +83,25 @@
</value>
</item>
<item>
<key> <string>center</string> </key>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<key> <string>left</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>right</string> </key>
<key> <string>right</string> </key>
<value>
<list/>
</value>
......@@ -129,7 +123,7 @@
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_dialog</string> </value>
<value> <string>form_view_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
......
......@@ -9,12 +9,6 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......@@ -42,12 +36,6 @@
<tuple/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Project_printAsODSMonthly</string> </value>
......@@ -87,7 +75,6 @@
<key> <string>left</string> </key>
<value>
<list>
<string>your_target_language</string>
<string>your_report_depth</string>
</list>
</value>
......@@ -95,7 +82,11 @@
<item>
<key> <string>right</string> </key>
<value>
<list/>
<list>
<string>your_simulation_state</string>
<string>your_from_date</string>
<string>your_at_date</string>
</list>
</value>
</item>
</dictionary>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>your_at_date</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>your_at_date</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Project_viewDialogFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>your_from_date</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>your_from_date</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Project_viewDialogFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -17,7 +17,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_target_language</string> </value>
<value> <string>your_simulation_state</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -74,11 +74,11 @@
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>your_target_language</string> </value>
<value> <string>your_simulation_state</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewDialogFieldLibrary</string> </value>
<value> <string>Project_viewDialogFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
......
596
\ No newline at end of file
597
\ No newline at end of file
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