Commit d1a3c855 authored by Jérome Perrin's avatar Jérome Perrin

project task fast input

fix internal API mis-use and other small fixes

See merge request !1583
parents 940f40ce b84bea2c
"""At first call, this script prefill values for all tasks that are """At first call, this script prefills values for all tasks that are
going to be created. If values are already there, this script check if going to be created. If values are already there, this script check that
informations are correct. information is correct.
""" """
context.log('source_project_title', source_project_title)
portal = context.getPortalObject() portal = context.getPortalObject()
line_portal_type = "Sale Order Line" line_portal_type = "Sale Order Line"
request = context.REQUEST request = context.REQUEST
from string import zfill from string import zfill
from Products.ERP5Type.Document import newTempBase from Products.PythonScripts.standard import Object
from Products.ERP5Type.Message import translateString from Products.ERP5Type.Message import translateString
context.log('original listbox', listbox)
initial_value_dict = {} initial_value_dict = {}
for line in (listbox or []): for line in (listbox or []):
initial_value_dict[line['listbox_key']] = line initial_value_dict[line['listbox_key']] = line
...@@ -19,7 +17,7 @@ listbox = [] ...@@ -19,7 +17,7 @@ listbox = []
validation_errors = {} validation_errors = {}
def getRecursiveLineList(current, line_list): def getRecursiveLineList(current, line_list):
# We parse recursively all delivery line and we keep only ones # We parse recursively all delivery line and we keep only ones
# without childs # without child
sub_line_list = current.objectValues(portal_type=line_portal_type) sub_line_list = current.objectValues(portal_type=line_portal_type)
if len(sub_line_list) == 0: if len(sub_line_list) == 0:
if current.getPortalType() == line_portal_type: if current.getPortalType() == line_portal_type:
...@@ -29,13 +27,10 @@ def getRecursiveLineList(current, line_list): ...@@ -29,13 +27,10 @@ def getRecursiveLineList(current, line_list):
getRecursiveLineList(sub_line, line_list) getRecursiveLineList(sub_line, line_list)
line_list = [] line_list = []
getRecursiveLineList(context, line_list) getRecursiveLineList(context, line_list)
context.log("line_list", line_list)
i = 1 i = 1
project_search_dict = {} project_search_dict = {}
portal = context.getPortalObject()
for line in line_list: for line in line_list:
line_dict = {} line_dict = {}
#line_dict['listbox_key'] = "%s" % line_id
key = zfill(i,3) key = zfill(i,3)
for property_name in ('title', 'quantity_unit_title', 'quantity', for property_name in ('title', 'quantity_unit_title', 'quantity',
'resource_title', 'total_price', 'price', 'resource_title', 'total_price', 'price',
...@@ -65,13 +60,13 @@ for line in line_list: ...@@ -65,13 +60,13 @@ for line in line_list:
else: else:
line_dict['source_project_relative_url'] = result[0].getRelativeUrl() line_dict['source_project_relative_url'] = result[0].getRelativeUrl()
if error_message: if error_message:
error = newTempBase(context, key) validation_errors['listbox_source_project_title_new_%s' % key] = Object(
error.edit(error_text=error_message) field_id='listbox_source_project_title_new_%s' % key,
validation_errors['listbox_source_project_title_new_%s' % key] = error getMessage=lambda translateString, message=error_message: translateString(message),
)
listbox.append(line_dict) listbox.append(line_dict)
i += 1 i += 1
context.log('listbox', listbox)
context.Base_updateDialogForm(listbox=listbox,update=1,kw=kw) context.Base_updateDialogForm(listbox=listbox,update=1,kw=kw)
if len(validation_errors): if len(validation_errors):
...@@ -101,6 +96,5 @@ if create and len(validation_errors) == 0: ...@@ -101,6 +96,5 @@ if create and len(validation_errors) == 0:
destination_section=delivery_line.getDestinationSection(), destination_section=delivery_line.getDestinationSection(),
destination_decision=delivery_line.getDestinationDecision()) destination_decision=delivery_line.getDestinationDecision())
return context.Base_redirect(form_id, keep_items=dict( return context.Base_redirect(form_id, keep_items=dict(
portal_status_message=translateString('%s Tasks Created.' %(len(listbox),)))) portal_status_message=translateString('${task_count} Tasks Created.', mapping={'task_count': len(listbox)})))
return context.Delivery_viewTaskFastInputDialog(listbox=listbox, **kw) return context.Delivery_viewTaskFastInputDialog(listbox=listbox, **kw)
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