diff --git a/support/doctype/communication/communication.txt b/support/doctype/communication/communication.txt index 09f83bb3c1..ea457550a7 100644 --- a/support/doctype/communication/communication.txt +++ b/support/doctype/communication/communication.txt @@ -4,7 +4,7 @@ "docstatus": 0, "creation": "2012-11-14 12:25:16", "modified_by": "Administrator", - "modified": "2012-11-26 11:17:28" + "modified": "2012-11-26 12:41:59" }, { "autoname": "naming_series:", @@ -12,7 +12,7 @@ "name": "__common__", "doctype": "DocType", "module": "Support", - "in_dialog": 1, + "in_dialog": 0, "document_type": "Master", "description": "Keep a track of all communications" }, diff --git a/support/doctype/support_ticket/support_ticket.py b/support/doctype/support_ticket/support_ticket.py index 43c650803b..e8189f9da9 100644 --- a/support/doctype/support_ticket/support_ticket.py +++ b/support/doctype/support_ticket/support_ticket.py @@ -106,22 +106,40 @@ class DocType(TransactionBase): d.subject = self.doc.subject d.email_address = from_email or webnotes.user.name email_addr = email.utils.parseaddr(d.email_address)[1] - d.contact = webnotes.conn.get_value("Contact", {"email_id": email_addr}, "name") or None - d.lead = webnotes.conn.get_value("Lead", {"email_id": email_addr}, "name") or None + self.set_lead_and_contact(d) d.support_ticket = self.doc.name d.content = response d.communication_medium = "Email" d.save(1) - - if not d.lead and not d.contact: - self.make_lead(d, email_addr[0]) + def set_lead_and_contact(self, d): + # set contact + if self.doc.contact: + d.contact = self.doc.contact + else: + d.contact = webnotes.conn.get_value("Contact", {"email_id": email_addr}, "name") or None + if d.contact: + webnotes.conn.set(self.doc, "contact", d.contact) + + if self.doc.lead: + d.lead = self.doc.lead + else: + d.lead = webnotes.conn.get_value("Lead", {"email_id": email_addr}, "name") or None + if d.lead: + webnotes.conn.set(self.doc, "lead", d.lead) + + # not linked to any lead / contact, create new lead + if not d.lead and not d.contact: + d.lead = self.make_lead(d, email_addr[0]) + webnotes.conn.set(self.doc, "lead", d.lead) + def make_lead(self, d, real_name): d = webnotes.doc("Lead") d.lead_name = real_name or d.email_address d.email_id = d.email_address d.source = "Email" d.save(1) + return d.name def close_ticket(self): webnotes.conn.set(self.doc,'status','Closed') diff --git a/support/doctype/support_ticket/support_ticket.txt b/support/doctype/support_ticket/support_ticket.txt index c820bc61d7..8259954b14 100644 --- a/support/doctype/support_ticket/support_ticket.txt +++ b/support/doctype/support_ticket/support_ticket.txt @@ -4,7 +4,7 @@ "docstatus": 0, "creation": "2012-11-02 17:17:05", "modified_by": "Administrator", - "modified": "2012-11-26 11:17:10" + "modified": "2012-11-26 12:54:25" }, { "autoname": "naming_series:", @@ -138,6 +138,22 @@ "depends_on": "eval:!doc.__islocal", "permlevel": 1 }, + { + "doctype": "DocField", + "label": "Lead", + "options": "Lead", + "fieldname": "lead", + "fieldtype": "Link", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Contact", + "options": "Contact", + "fieldname": "contact", + "fieldtype": "Link", + "permlevel": 0 + }, { "print_hide": 1, "oldfieldtype": "Link", @@ -166,36 +182,6 @@ "permlevel": 2, "in_filter": 1 }, - { - "doctype": "DocField", - "label": "Address", - "fieldname": "address_display", - "fieldtype": "Small Text", - "permlevel": 2 - }, - { - "doctype": "DocField", - "label": "Contact Name", - "fieldname": "contact_display", - "fieldtype": "Data", - "permlevel": 2 - }, - { - "doctype": "DocField", - "label": "Mobile No", - "fieldname": "contact_mobile", - "fieldtype": "Data", - "permlevel": 2 - }, - { - "oldfieldtype": "Data", - "doctype": "DocField", - "label": "Contact Email", - "oldfieldname": "contact_no", - "fieldname": "contact_email", - "fieldtype": "Data", - "permlevel": 2 - }, { "default": "Today", "oldfieldtype": "Date", @@ -225,20 +211,6 @@ "depends_on": "eval:!doc.__islocal", "permlevel": 1 }, - { - "depends_on": "eval:!doc.__islocal", - "search_index": 1, - "colour": "White:FFF", - "doctype": "DocField", - "label": "Allocated To", - "oldfieldname": "allocated_to", - "permlevel": 1, - "fieldname": "allocated_to", - "fieldtype": "Link", - "oldfieldtype": "Link", - "options": "Profile", - "in_filter": 1 - }, { "no_copy": 1, "oldfieldtype": "Text", @@ -246,7 +218,7 @@ "label": "Resolution Details", "oldfieldname": "resolution_details", "fieldname": "resolution_details", - "fieldtype": "Text", + "fieldtype": "Small Text", "depends_on": "eval:!doc.__islocal", "permlevel": 1 },