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

officejs_support_request: create only one support request

Also:
 * don't immediate reindex, this is a coding crime
 * don't search catalog by ID, use direct module access
parent bfaba5fb
from Products.ERP5Type.ImmediateReindexContextManager import ImmediateReindexContextManager
portal = context.getPortalObject()
logged_in_user_value = portal.portal_membership.getAuthenticatedMember().getUserValue()
now = DateTime()
# default_field_your_resource,field_your_title, description, field_your_project, default_field_your_project, form_id, field_your_resource, dialog_id, resource, title, file, project, dialog_method, field_my_description, field_your_file=None
project_list = portal.portal_catalog(portal_type="Project", id=project) # with id keyword, this function will return a sequence data type which contains one element.
project_object = project_list[0].getObject()
project_object = portal.project_module[project]
with ImmediateReindexContextManager() as immediate_reindex_context_manager:
support_request = portal.support_request_module.newContent(
immediate_reindex=immediate_reindex_context_manager,
portal_type='Support Request',
title=title,
resource="service_module/" + resource,
)
# - Reference = automatically generated - already implemented
# - Requester = current user person
# - Start date = now
# - State = submitted
# - Billing Supplier = Project related Billing Supplier
# - Location = Project related Location
# - Supervisor = Project related Supervisor
support_request = portal.support_request_module.newContent(
support_request = portal.support_request_module.newContent(
portal_type='Support Request',
title=title,
resource="service_module/" + resource,
......@@ -34,10 +15,9 @@ with ImmediateReindexContextManager() as immediate_reindex_context_manager:
source_project_value = project_object,
destination_value = project_object.getDestinationValue(),
start_date=now,
)
)
support_request.submit()
support_request.submit()
if description is not None or file is not None:
portal.post_module.PostModule_createHTMLPostForSupportRequest(
......
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