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() portal = context.getPortalObject()
logged_in_user_value = portal.portal_membership.getAuthenticatedMember().getUserValue() logged_in_user_value = portal.portal_membership.getAuthenticatedMember().getUserValue()
now = DateTime() 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_object = portal.project_module[project]
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() support_request = portal.support_request_module.newContent(
portal_type='Support Request',
with ImmediateReindexContextManager() as immediate_reindex_context_manager: title=title,
support_request = portal.support_request_module.newContent( resource="service_module/" + resource,
immediate_reindex=immediate_reindex_context_manager, destination_decision_value=logged_in_user_value,
portal_type='Support Request', source_decision_value = project_object.getSourceDecisionValue(),
title=title, source_section_value = project_object.getSourceSectionValue(),
resource="service_module/" + resource, source_project_value = project_object,
) destination_value = project_object.getDestinationValue(),
start_date=now,
# - 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(
portal_type='Support Request',
title=title,
resource="service_module/" + resource,
destination_decision_value=logged_in_user_value,
source_decision_value = project_object.getSourceDecisionValue(),
source_section_value = project_object.getSourceSectionValue(),
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: if description is not None or file is not None:
portal.post_module.PostModule_createHTMLPostForSupportRequest( 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