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
Pipeline #20604 failed with stage
in 0 seconds
"""At first call, this script prefill values for all tasks that are
going to be created. If values are already there, this script check if
informations are correct.
"""At first call, this script prefills values for all tasks that are
going to be created. If values are already there, this script check that
information is correct.
"""
context.log('source_project_title', source_project_title)
portal = context.getPortalObject()
line_portal_type = "Sale Order Line"
request = context.REQUEST
from string import zfill
from Products.ERP5Type.Document import newTempBase
from Products.PythonScripts.standard import Object
from Products.ERP5Type.Message import translateString
context.log('original listbox', listbox)
initial_value_dict = {}
for line in (listbox or []):
initial_value_dict[line['listbox_key']] = line
......@@ -19,7 +17,7 @@ listbox = []
validation_errors = {}
def getRecursiveLineList(current, line_list):
# 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)
if len(sub_line_list) == 0:
if current.getPortalType() == line_portal_type:
......@@ -29,13 +27,10 @@ def getRecursiveLineList(current, line_list):
getRecursiveLineList(sub_line, line_list)
line_list = []
getRecursiveLineList(context, line_list)
context.log("line_list", line_list)
i = 1
project_search_dict = {}
portal = context.getPortalObject()
for line in line_list:
line_dict = {}
#line_dict['listbox_key'] = "%s" % line_id
key = zfill(i,3)
for property_name in ('title', 'quantity_unit_title', 'quantity',
'resource_title', 'total_price', 'price',
......@@ -65,13 +60,13 @@ for line in line_list:
else:
line_dict['source_project_relative_url'] = result[0].getRelativeUrl()
if error_message:
error = newTempBase(context, key)
error.edit(error_text=error_message)
validation_errors['listbox_source_project_title_new_%s' % key] = error
validation_errors['listbox_source_project_title_new_%s' % key] = Object(
field_id='listbox_source_project_title_new_%s' % key,
getMessage=lambda translateString, message=error_message: translateString(message),
)
listbox.append(line_dict)
i += 1
context.log('listbox', listbox)
context.Base_updateDialogForm(listbox=listbox,update=1,kw=kw)
if len(validation_errors):
......@@ -101,6 +96,5 @@ if create and len(validation_errors) == 0:
destination_section=delivery_line.getDestinationSection(),
destination_decision=delivery_line.getDestinationDecision())
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)
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