[enhance] Add Issue Type and Opportunity Type masters (#11598)

* [enhance] added & linked Issue Type & Opportunity Type with opportunity

* [patch] create issue and opportunity type from the custom field if available

* [minor] issue_type and opportunity type should be mandatory

* [patches] removed try catch from the patch

* [fix] patch

* [refactor] cleanup issue/opportunity type
This commit is contained in:
Rushabh Mehta
2017-11-16 17:03:52 +05:30
committed by GitHub
parent 46be9896a9
commit a5ebebd09c
27 changed files with 522 additions and 81 deletions

View File

@@ -9,16 +9,16 @@ from frappe.utils import cint, formatdate
@frappe.whitelist(allow_guest=True)
def send_message(subject="Website Query", message="", sender="", status="Open"):
from frappe.www.contact import send_message as website_send_message
lead = customer = None
from frappe.www.contact import send_message as website_send_message
lead = customer = None
website_send_message(subject, message, sender)
website_send_message(subject, message, sender)
customer = frappe.db.sql("""select distinct dl.link_name from `tabDynamic Link` dl
left join `tabContact` c on dl.parent=c.name where dl.link_doctype='Customer'
and c.email_id='{email_id}'""".format(email_id=sender))
customer = frappe.db.sql("""select distinct dl.link_name from `tabDynamic Link` dl
left join `tabContact` c on dl.parent=c.name where dl.link_doctype='Customer'
and c.email_id='{email_id}'""".format(email_id=sender))
if not customer:
if not customer:
lead = frappe.db.get_value('Lead', dict(email_id=sender))
if not lead:
new_lead = frappe.get_doc(dict(
@@ -27,33 +27,33 @@ def send_message(subject="Website Query", message="", sender="", status="Open"):
lead_name = sender.split('@')[0].title()
)).insert(ignore_permissions=True)
opportunity = frappe.get_doc(dict(
doctype ='Opportunity',
enquiry_from = 'Customer' if customer else 'Lead',
status = 'Open',
title = subject,
contact_email = sender,
to_discuss = message
))
opportunity = frappe.get_doc(dict(
doctype ='Opportunity',
enquiry_from = 'Customer' if customer else 'Lead',
status = 'Open',
title = subject,
contact_email = sender,
to_discuss = message
))
if customer:
opportunity.customer = customer[0][0]
elif lead:
opportunity.lead = lead
else:
opportunity.lead = new_lead.name
if customer:
opportunity.customer = customer[0][0]
elif lead:
opportunity.lead = lead
else:
opportunity.lead = new_lead.name
opportunity.insert(ignore_permissions=True)
opportunity.insert(ignore_permissions=True)
comm = frappe.get_doc({
"doctype":"Communication",
"subject": subject,
"content": message,
"sender": sender,
"sent_or_received": "Received",
'reference_doctype': 'Opportunity',
'reference_name': opportunity.name
})
comm.insert(ignore_permissions=True)
comm = frappe.get_doc({
"doctype":"Communication",
"subject": subject,
"content": message,
"sender": sender,
"sent_or_received": "Received",
'reference_doctype': 'Opportunity',
'reference_name': opportunity.name
})
comm.insert(ignore_permissions=True)
return "okay"
return "okay"