Make the communication from the issue webform (#14015)

This commit is contained in:
Manas Solanki 2018-05-16 10:47:02 +05:30 committed by Rushabh Mehta
parent 292f46fec0
commit 1b48fde986
4 changed files with 74 additions and 3 deletions

View File

@ -926,6 +926,37 @@
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "via_customer_portal",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Via Customer Portal",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}
],
"has_web_view": 0,
@ -939,7 +970,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-04-13 13:03:14.748090",
"modified": "2018-05-07 05:53:20.684275",
"modified_by": "Administrator",
"module": "Support",
"name": "Issue",

View File

@ -17,6 +17,8 @@ class Issue(Document):
return "{0}: {1}".format(_(self.status), self.subject)
def validate(self):
if (self.get("__islocal") and self.via_customer_portal):
self.flags.create_communication = True
if not self.raised_by:
self.raised_by = frappe.session.user
self.update_status()
@ -26,6 +28,12 @@ class Issue(Document):
from frappe.desk.form.assign_to import clear
clear(self.doctype, self.name)
def on_update(self):
# create the communication email and remove the description
if (self.flags.create_communication and self.via_customer_portal):
self.create_communication()
self.flags.communication_created = None
def set_lead_contact(self, email_id):
import email.utils
email_id = email.utils.parseaddr(email_id)[1]
@ -53,6 +61,26 @@ class Issue(Document):
# if no date, it should be set as None and not a blank string "", as per mysql strict config
self.resolution_date = None
def create_communication(self):
communication = frappe.new_doc("Communication")
communication.update({
"communication_type": "Communication",
"communication_medium": "Email",
"sent_or_received": "Received",
"email_status": "Open",
"subject": self.subject,
"sender": self.raised_by,
"content": self.description,
"status": "Linked",
"reference_doctype": "Issue",
"reference_name": self.name
})
communication.ignore_permissions = True
communication.ignore_mandatory = True
communication.save()
self.db_set("description", "")
def get_list_context(context=None):
return {
"title": _("Issues"),

View File

@ -18,7 +18,7 @@
"is_standard": 1,
"login_required": 1,
"max_attachment_size": 0,
"modified": "2017-07-25 22:49:10.762704",
"modified": "2018-05-07 05:54:22.213127",
"modified_by": "Administrator",
"module": "Support",
"name": "issues",
@ -83,6 +83,17 @@
"max_value": 0,
"read_only": 0,
"reqd": 0
},
{
"default": "1",
"fieldname": "via_customer_portal",
"fieldtype": "Check",
"hidden": 1,
"label": "Via Customer Portal",
"max_length": 0,
"max_value": 0,
"read_only": 1,
"reqd": 0
}
]
}

View File

@ -4,4 +4,5 @@ import frappe
def get_context(context):
# do your magic here
pass
if context.doc:
context.read_only = 1