Commit 336eeae9 authored by Sebastien Robin's avatar Sebastien Robin

add fast input to create task from order lines

parent 8e3f9600
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </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>return context.Delivery_updateTaskFastInputDialog(create=1,\n
listbox=listbox,source_project_title=source_project_title,\n
form_id=form_id, **kw)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>listbox=None,source_project_title=\'\', form_id=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Delivery_setTaskFastInputDialog</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </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[
"""At first call, this script prefill values for all tasks that are\n
going to be created. If values are already there, this script check if\n
informations are correct.\n
"""\n
context.log(\'source_project_title\', source_project_title)\n
portal = context.getPortalObject()\n
line_portal_type = "Sale Order Line"\n
request = context.REQUEST\n
from string import zfill\n
from Products.ERP5Type.Document import newTempBase\n
from Products.ERP5Type.Message import translateString\n
\n
context.log(\'original listbox\', listbox)\n
initial_value_dict = {}\n
for line in (listbox or []):\n
initial_value_dict[line[\'listbox_key\']] = line\n
\n
listbox = []\n
validation_errors = {}\n
def getRecursiveLineList(current, line_list):\n
# We parse recursively all delivery line and we keep only ones\n
# without childs\n
sub_line_list = current.objectValues(portal_type=line_portal_type)\n
if len(sub_line_list) == 0:\n
if current.getPortalType() == line_portal_type:\n
line_list.append(current)\n
else:\n
for sub_line in sub_line_list:\n
getRecursiveLineList(sub_line, line_list)\n
line_list = []\n
getRecursiveLineList(context, line_list)\n
context.log("line_list", line_list)\n
i = 1\n
project_search_dict = {}\n
portal = context.getPortalObject()\n
for line in line_list:\n
line_dict = {}\n
line_id = "%s" % line.getUid()\n
#line_dict[\'listbox_key\'] = "%s" % line_id\n
key = zfill(i,3)\n
for property_name in (\'title\', \'quantity_unit_title\', \'quantity\',\n
\'resource_title\', \'total_price\', \'price\',\n
\'reference\', \'relative_url\'):\n
property_value = line.getProperty(property_name)\n
line_dict[property_name] = line.getProperty(property_name)\n
request.form["field_listbox_%s_new_%s"% (property_name, key)] = \\\n
property_value\n
line_dict.update(**initial_value_dict.get(key, {}))\n
if line_dict.get(\'source_project_title\', \'\') == \'\':\n
line_dict[\'source_project_title\'] = source_project_title\n
line_source_project_title = line_dict.get(\'source_project_title\', \'\')\n
request.form["field_listbox_%s_new_%s"% (\'source_project_title\', key)] = \\\n
line_source_project_title\n
if line_source_project_title != \'\':\n
# Check if we have exactly one corresponding project\n
result = project_search_dict.get(line_source_project_title, None)\n
error_message = None\n
if result is None:\n
result = portal.portal_catalog(portal_type=(\'Project\', \'Project Line\'),\n
title=line_source_project_title)\n
project_search_dict[line_source_project_title] = result\n
if len(result) == 0:\n
error_message = "No such project"\n
elif len(result) > 1:\n
error_message = "Too many matching projects"\n
else:\n
line_dict[\'source_project_relative_url\'] = result[0].getRelativeUrl()\n
if error_message:\n
error = newTempBase(context, key)\n
error.edit(error_text=error_message)\n
validation_errors[\'listbox_source_project_title_new_%s\' % key] = error\n
listbox.append(line_dict)\n
i += 1\n
\n
context.log(\'listbox\', listbox)\n
context.Base_updateDialogForm(listbox=listbox,update=1,kw=kw)\n
\n
if len(validation_errors):\n
request.set(\'field_errors\',validation_errors)\n
kw[\'REQUEST\'] = request\n
\n
# if called from the validate action we create tasks\n
if create and len(validation_errors) == 0:\n
for line in listbox:\n
delivery_line = portal.restrictedTraverse(line[\'relative_url\'])\n
task = portal.task_module.newContent(\n
title=delivery_line.getTitle(),\n
source_project=line[\'source_project_relative_url\'],\n
source=delivery_line.getSourceTrade(),\n
reference=delivery_line.getReference(),\n
task_line_quantity=delivery_line.getQuantity(),\n
task_line_price=delivery_line.getPrice(),\n
task_line_quantity_unit=delivery_line.getQuantityUnit(),\n
task_line_resource=delivery_line.getResource(),\n
start_date=delivery_line.getStartDate(),\n
stop_date=delivery_line.getStopDate(),\n
description=delivery_line.getDescription(),\n
price_currency=context.getPriceCurrency(),\n
source_section=delivery_line.getSourceSection(),\n
destination=delivery_line.getDestination(),\n
causality=delivery_line.getRelativeUrl(),\n
destination_section=delivery_line.getDestinationSection(),\n
destination_decision=delivery_line.getDestinationDecision())\n
return context.Base_redirect(form_id, keep_items=dict(\n
portal_status_message=translateString(\'%s Tasks Created.\' %(len(listbox),))))\n
\n
return context.Delivery_viewTaskFastInputDialog(listbox=listbox, **kw)\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>listbox=None,source_project_title=\'\', create=0, form_id=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Delivery_updateTaskFastInputDialog</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5Form" module="Products.ERP5Form.Form"/>
</pickle>
<pickle>
<dictionary>
<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>action</string> </key>
<value> <string>Delivery_setTaskFastInputDialog</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string>application/x-www-form-urlencoded</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>
<string>listbox</string>
</list>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list>
<string>listbox_source_project_title</string>
</list>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>my_source_project_title</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Delivery_viewTaskFastInputDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>Delivery_viewDeliveryFastInputDialog</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>Add Tasks</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>Delivery_updateTaskFastInputDialog</string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>columns</string>
<string>editable_columns</string>
<string>lines</string>
<string>list_method</string>
<string>portal_types</string>
<string>search_columns</string>
<string>selection_name</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox</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>portal_types</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</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>columns</string> </key>
<value>
<list>
<tuple>
<string>title</string>
<string>Product or Service</string>
</tuple>
<tuple>
<string>reference</string>
<string>Reference</string>
</tuple>
<tuple>
<string>resource_title</string>
<string>Product or Service</string>
</tuple>
<tuple>
<string>variation_category_list</string>
<string>Variation</string>
</tuple>
<tuple>
<string>quantity</string>
<string>Quantity</string>
</tuple>
<tuple>
<string>quantity_unit_title</string>
<string>Quantity Unit</string>
</tuple>
<tuple>
<string>price</string>
<string>Price</string>
</tuple>
<tuple>
<string>total_price</string>
<string>Total Price</string>
</tuple>
<tuple>
<string>source_project_title</string>
<string>Project</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>editable_columns</string> </key>
<value>
<list>
<tuple>
<string>source_project_title</string>
<string>Project</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_listbox</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewTradeFieldLibrary</string> </value>
</item>
<item>
<key> <string>lines</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>list_method</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>portal_types</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>search_columns</string> </key>
<value>
<list>
<tuple>
<string>title</string>
<string>Product or Service</string>
</tuple>
<tuple>
<string>reference</string>
<string>Reference</string>
</tuple>
<tuple>
<string>quantity</string>
<string>Quantity</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>selection_name</string> </key>
<value> <string>delivery_task_fast_input_selection</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>Add Lines</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python:((here.getPortalType(), here.getPortalType()),)</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="Method" module="Products.Formulator.MethodField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>ListBox_initializeFastInput</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
825
\ No newline at end of file
827
\ 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