Merge branch 'master' of github.com:webnotes/erpnext
This commit is contained in:
commit
4b29c89692
@ -9,17 +9,8 @@ from core.doctype.communication.communication import make
|
|||||||
|
|
||||||
def add_sales_communication(subject, content, sender, real_name, mail=None,
|
def add_sales_communication(subject, content, sender, real_name, mail=None,
|
||||||
status="Open", date=None):
|
status="Open", date=None):
|
||||||
def set_status(doctype, name):
|
|
||||||
w = webnotes.bean(doctype, name)
|
|
||||||
w.ignore_permissions = True
|
|
||||||
w.doc.status = is_system_user and "Replied" or status
|
|
||||||
w.doc.save()
|
|
||||||
if mail:
|
|
||||||
mail.save_attachments_in_doc(w.doc)
|
|
||||||
|
|
||||||
lead_name = webnotes.conn.get_value("Lead", {"email_id": sender})
|
lead_name = webnotes.conn.get_value("Lead", {"email_id": sender})
|
||||||
contact_name = webnotes.conn.get_value("Contact", {"email_id": sender})
|
contact_name = webnotes.conn.get_value("Contact", {"email_id": sender})
|
||||||
is_system_user = webnotes.conn.get_value("Profile", sender)
|
|
||||||
|
|
||||||
if not (lead_name or contact_name):
|
if not (lead_name or contact_name):
|
||||||
# none, create a new Lead
|
# none, create a new Lead
|
||||||
@ -34,14 +25,13 @@ def add_sales_communication(subject, content, sender, real_name, mail=None,
|
|||||||
lead.insert()
|
lead.insert()
|
||||||
lead_name = lead.doc.name
|
lead_name = lead.doc.name
|
||||||
|
|
||||||
make(content=content, sender=sender, subject=subject,
|
message = make(content=content, sender=sender, subject=subject,
|
||||||
lead=lead_name, contact=contact_name, date=date)
|
lead=lead_name, contact=contact_name, date=date)
|
||||||
|
|
||||||
if contact_name:
|
if mail:
|
||||||
set_status("Contact", contact_name)
|
# save attachments to parent if from mail
|
||||||
elif lead_name:
|
bean = webnotes.bean("Contact" if contact_name else "Lead", contact_name or lead_name)
|
||||||
set_status("Lead", lead_name)
|
mail.save_attachments_in_doc(bean.doc)
|
||||||
|
|
||||||
|
|
||||||
class SalesMailbox(POP3Mailbox):
|
class SalesMailbox(POP3Mailbox):
|
||||||
def setup(self, args=None):
|
def setup(self, args=None):
|
||||||
|
@ -20,7 +20,7 @@ def send_message(subject="Website Query", message="", sender="", status="Open"):
|
|||||||
|
|
||||||
# make lead / communication
|
# make lead / communication
|
||||||
from selling.doctype.lead.get_leads import add_sales_communication
|
from selling.doctype.lead.get_leads import add_sales_communication
|
||||||
add_sales_communication(subject or "Website Query", message, sender, sender,
|
message = add_sales_communication(subject or "Website Query", message, sender, sender,
|
||||||
mail=None, status=status)
|
mail=None, status=status)
|
||||||
|
|
||||||
# guest method, cap max writes per hour
|
# guest method, cap max writes per hour
|
||||||
@ -29,4 +29,4 @@ def send_message(subject="Website Query", message="", sender="", status="Open"):
|
|||||||
webnotes.response["message"] = "Sorry: we believe we have received an unreasonably high number of requests of this kind. Please try later"
|
webnotes.response["message"] = "Sorry: we believe we have received an unreasonably high number of requests of this kind. Please try later"
|
||||||
return
|
return
|
||||||
|
|
||||||
webnotes.response["message"] = 'Thank You'
|
webnotes.response.status = "okay"
|
||||||
|
@ -26,7 +26,12 @@ $(document).ready(function() {
|
|||||||
sender: email,
|
sender: email,
|
||||||
message: message,
|
message: message,
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
msgprint(r.message);
|
if(r.status==="okay") {
|
||||||
|
msgprint(r.message or "Sent")
|
||||||
|
} else {
|
||||||
|
msgprint("There were errors");
|
||||||
|
console.log(r.exc);
|
||||||
|
}
|
||||||
$(':input').val('');
|
$(':input').val('');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user