Commit 54b2973f authored by Romain Courteaud's avatar Romain Courteaud

Add an action to duplicate Task periodically

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17453 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4c234fdf
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.CMFCore.ActionInformation</string>
<string>ActionInformation</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_action</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>duplicate_task</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>60.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Duplicate</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Products.CMFCore.Expression</string>
<string>Expression</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Task_duplicateFormDialog</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<tuple>
<string>Products.CMFCore.Expression</string>
<string>Expression</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python: portal.Base_checkPermission(\'task_module\', \'Add portal content\')</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</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>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
from Products.ERP5Type.DateUtils import addToDate\n
N_ = context.Base_translateString\n
\n
task_portal_type = \'Task\'\n
task_module = context.getDefaultModule(task_portal_type)\n
\n
def validateDay(date):\n
if (periodicity_month_day_list in ([], None, ())):\n
return 1\n
elif len(periodicity_month_day_list) > 0:\n
return date.day() in periodicity_month_day_list\n
\n
def validateWeek(date):\n
if (periodicity_week_day_list in ([], None, ())) and \\\n
(periodicity_week_list is None):\n
return 1\n
if periodicity_week_day_list not in (None, (), []):\n
if not (date.Day() in periodicity_week_day_list):\n
return 0\n
if periodicity_week_list not in (None, (), []):\n
if not (date.week() in periodicity_week_list):\n
return 0\n
return 1\n
\n
def validateMonth(date):\n
if (periodicity_month_list in ([], None, ())):\n
return 1\n
elif len(periodicity_month_list) > 0:\n
return date.month() in periodicity_month_list\n
\n
def getNextPeriodicalDate(current_date):\n
next_start_date = current_date\n
previous_date = next_start_date\n
next_start_date = addToDate(next_start_date, day=1)\n
while 1:\n
if (validateDay(next_start_date)) and \\\n
(validateWeek(next_start_date)) and \\\n
(validateMonth(next_start_date)):\n
break\n
else:\n
next_start_date = addToDate(next_start_date, day=1)\n
return next_start_date\n
\n
def getDatePeriodList(start_date):\n
result = []\n
# First date has to respect the periodicity config\n
next_start_date = getNextPeriodicalDate(start_date)\n
while (next_start_date is not None) and \\\n
(next_start_date <= periodicity_stop_date):\n
result.append(next_start_date)\n
next_start_date = getNextPeriodicalDate(next_start_date)\n
return result\n
\n
\n
start_date = context.getStartDate()\n
if start_date is None:\n
return context.REQUEST.RESPONSE.redirect(\n
\'%s?portal_status_message=%s+%s.\' % (context.absolute_url(), \n
N_(\'Tasks+can+not+be+created:\'), \n
N_(\'Start+Date+is+None\')))\n
else:\n
date_list = getDatePeriodList(start_date)\n
for next_date in date_list:\n
context.activate(activity="SQLQueue").Task_duplicate(next_date)\n
return context.REQUEST.RESPONSE.redirect(\n
\'%s?portal_status_message=%s+%s.\' % (context.absolute_url(), \n
len(date_list), \n
N_(\'Tasks+created\')))\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<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>periodicity_month_day_list=(), periodicity_month_list=(), periodicity_week_list=(), periodicity_stop_date=None, periodicity_week_day_list=(), **kw</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>5</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>periodicity_month_day_list</string>
<string>periodicity_month_list</string>
<string>periodicity_week_list</string>
<string>periodicity_stop_date</string>
<string>periodicity_week_day_list</string>
<string>kw</string>
<string>Products.ERP5Type.DateUtils</string>
<string>addToDate</string>
<string>_getattr_</string>
<string>context</string>
<string>N_</string>
<string>task_portal_type</string>
<string>task_module</string>
<string>validateDay</string>
<string>validateWeek</string>
<string>validateMonth</string>
<string>getNextPeriodicalDate</string>
<string>getDatePeriodList</string>
<string>start_date</string>
<string>None</string>
<string>date_list</string>
<string>_getiter_</string>
<string>next_date</string>
<string>len</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<tuple/>
<tuple/>
<tuple/>
<none/>
<tuple/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Task_calculateDuplication</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</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>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from Products.ERP5Type.DateUtils import addToDate\n
\n
task_portal_type = \'Task\'\n
task_module = context.getDefaultModule(task_portal_type)\n
\n
cb_data = task_module.manage_copyObjects([context.getId()])\n
copied, = task_module.manage_pasteObjects(cb_data)\n
pasted_task = task_module[copied[\'new_id\']]\n
\n
# Get task dates\n
start_date = pasted_task.getStartDate()\n
stop_date = pasted_task.getStopDate()\n
duration = int(stop_date) - int(start_date)\n
second_to_add = int(next_date) - int(start_date)\n
\n
for line in pasted_task.getMovementList():\n
# Get task line dates\n
line_start_date = line.getStartDate()\n
line_stop_date = line.getStopDate()\n
if (line_start_date is not start_date) or \\\n
(line_stop_date is not stop_date):\n
# Line dates are different from task dates\n
next_line_start_date = addToDate(line_start_date, second=second_to_add)\n
line.edit(\n
start_date=next_line_start_date,\n
stop_date=addToDate(next_line_start_date, second=duration),\n
)\n
\n
pasted_task.edit(\n
start_date=next_date,\n
stop_date=addToDate(next_date, second=duration),\n
)\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<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>next_date</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>next_date</string>
<string>Products.ERP5Type.DateUtils</string>
<string>addToDate</string>
<string>task_portal_type</string>
<string>_getattr_</string>
<string>context</string>
<string>task_module</string>
<string>cb_data</string>
<string>_getiter_</string>
<string>copied</string>
<string>_getitem_</string>
<string>pasted_task</string>
<string>start_date</string>
<string>stop_date</string>
<string>int</string>
<string>duration</string>
<string>second_to_add</string>
<string>line</string>
<string>line_start_date</string>
<string>line_stop_date</string>
<string>next_line_start_date</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Task_duplicate</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.ERP5Form.Form</string>
<string>ERP5Form</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Task_calculateDuplication</string> </value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>my_title</string>
<string>your_periodicity_stop_date</string>
<string>your_periodicity_week_day_list</string>
<string>your_periodicity_week_list</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list>
<string>your_periodicity_month_day_list</string>
<string>your_periodicity_month_list</string>
</list>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Task_duplicateFormDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>Task_duplicateFormDialog</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Duplicate</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
346
\ No newline at end of file
348
\ No newline at end of file
......@@ -69,6 +69,7 @@ Task Report | view
Task Report | view_discount
Task | apply_trade_condition
Task | constraint
Task | duplicate_task
Task | jump_to_related_task_report
Task | payment_condition
Task | profile_view
......
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