Merge branch 'edge' of github.com:webnotes/erpnext into edge
This commit is contained in:
commit
c5377e2583
@ -24,10 +24,6 @@ class JobsMailbox(POP3Mailbox):
|
|||||||
def setup(self, args=None):
|
def setup(self, args=None):
|
||||||
self.settings = args or webnotes.doc("Jobs Email Settings", "Jobs Email Settings")
|
self.settings = args or webnotes.doc("Jobs Email Settings", "Jobs Email Settings")
|
||||||
|
|
||||||
def check_mails(self):
|
|
||||||
return webnotes.conn.sql("select user from tabSessions where \
|
|
||||||
time_to_sec(timediff(now(), lastupdate)) < 1800")
|
|
||||||
|
|
||||||
def process_message(self, mail):
|
def process_message(self, mail):
|
||||||
if mail.from_email == self.settings.email_id:
|
if mail.from_email == self.settings.email_id:
|
||||||
return
|
return
|
||||||
@ -43,6 +39,7 @@ class JobsMailbox(POP3Mailbox):
|
|||||||
name = (mail.from_real_name and (mail.from_real_name + " - ") or "") \
|
name = (mail.from_real_name and (mail.from_real_name + " - ") or "") \
|
||||||
+ mail.from_email
|
+ mail.from_email
|
||||||
applicant = webnotes.model_wrapper({
|
applicant = webnotes.model_wrapper({
|
||||||
|
"creation": mail.date,
|
||||||
"doctype":"Job Applicant",
|
"doctype":"Job Applicant",
|
||||||
"applicant_name": name,
|
"applicant_name": name,
|
||||||
"email_id": mail.from_email,
|
"email_id": mail.from_email,
|
||||||
|
@ -20,11 +20,12 @@ from webnotes.utils import cstr, cint
|
|||||||
from webnotes.utils.email_lib.receive import POP3Mailbox
|
from webnotes.utils.email_lib.receive import POP3Mailbox
|
||||||
from core.doctype.communication.communication import make
|
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,
|
||||||
def set_status_open(doctype, name):
|
status="Open", date=None):
|
||||||
|
def set_status(doctype, name):
|
||||||
w = webnotes.model_wrapper(doctype, name)
|
w = webnotes.model_wrapper(doctype, name)
|
||||||
w.ignore_permissions = True
|
w.ignore_permissions = True
|
||||||
w.doc.status = "Open"
|
w.doc.status = is_system_user and "Replied" or status
|
||||||
w.doc.save()
|
w.doc.save()
|
||||||
if mail:
|
if mail:
|
||||||
mail.save_attachments_in_doc(w.doc)
|
mail.save_attachments_in_doc(w.doc)
|
||||||
@ -33,42 +34,38 @@ def add_sales_communication(subject, content, sender, real_name, mail=None):
|
|||||||
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)
|
is_system_user = webnotes.conn.get_value("Profile", sender)
|
||||||
|
|
||||||
if not is_system_user:
|
if not (lead_name or contact_name):
|
||||||
if contact_name:
|
|
||||||
set_status_open("Contact", contact_name)
|
|
||||||
elif lead_name:
|
|
||||||
set_status_open("Lead", lead_name)
|
|
||||||
else:
|
|
||||||
# none, create a new Lead
|
# none, create a new Lead
|
||||||
lead = webnotes.model_wrapper({
|
lead = webnotes.model_wrapper({
|
||||||
"doctype":"Lead",
|
"doctype":"Lead",
|
||||||
"lead_name": real_name or sender,
|
"lead_name": real_name or sender,
|
||||||
"email_id": sender,
|
"email_id": sender,
|
||||||
"status": "Open",
|
"status": status,
|
||||||
"source": "Email"
|
"source": "Email"
|
||||||
})
|
})
|
||||||
lead.ignore_permissions = True
|
lead.ignore_permissions = True
|
||||||
lead.insert()
|
lead.insert()
|
||||||
if mail:
|
lead_name = lead.doc.name
|
||||||
mail.save_attachments_in_doc(lead.doc)
|
|
||||||
|
|
||||||
make(content=content, sender=sender, subject=subject,
|
make(content=content, sender=sender, subject=subject,
|
||||||
lead=lead_name, contact=contact_name)
|
lead=lead_name, contact=contact_name, date=date)
|
||||||
|
|
||||||
|
if contact_name:
|
||||||
|
set_status("Contact", contact_name)
|
||||||
|
elif lead_name:
|
||||||
|
set_status("Lead", lead_name)
|
||||||
|
|
||||||
|
|
||||||
class SalesMailbox(POP3Mailbox):
|
class SalesMailbox(POP3Mailbox):
|
||||||
def setup(self, args=None):
|
def setup(self, args=None):
|
||||||
self.settings = args or webnotes.doc("Sales Email Settings", "Sales Email Settings")
|
self.settings = args or webnotes.doc("Sales Email Settings", "Sales Email Settings")
|
||||||
|
|
||||||
def check_mails(self):
|
|
||||||
return webnotes.conn.sql("select user from tabSessions where \
|
|
||||||
time_to_sec(timediff(now(), lastupdate)) < 1800")
|
|
||||||
|
|
||||||
def process_message(self, mail):
|
def process_message(self, mail):
|
||||||
if mail.from_email == self.settings.email_id:
|
if mail.from_email == self.settings.email_id:
|
||||||
return
|
return
|
||||||
|
|
||||||
add_sales_communication(mail.subject, mail.content, mail.form_email,
|
add_sales_communication(mail.subject, mail.content, mail.form_email,
|
||||||
mail.from_real_name, mail)
|
mail.from_real_name, mail=mail, date=mail.date)
|
||||||
|
|
||||||
def get_leads():
|
def get_leads():
|
||||||
if cint(webnotes.conn.get_value('Sales Email Settings', None, 'extract_emails')):
|
if cint(webnotes.conn.get_value('Sales Email Settings', None, 'extract_emails')):
|
||||||
|
@ -31,11 +31,6 @@ class SupportMailbox(POP3Mailbox):
|
|||||||
"password": self.email_settings.support_password
|
"password": self.email_settings.support_password
|
||||||
})
|
})
|
||||||
|
|
||||||
def check_mails(self):
|
|
||||||
self.auto_close_tickets()
|
|
||||||
return webnotes.conn.sql("select user from tabSessions where \
|
|
||||||
time_to_sec(timediff(now(), lastupdate)) < 1800")
|
|
||||||
|
|
||||||
def process_message(self, mail):
|
def process_message(self, mail):
|
||||||
if mail.from_email == self.email_settings.fields.get('support_email'):
|
if mail.from_email == self.email_settings.fields.get('support_email'):
|
||||||
return
|
return
|
||||||
@ -64,9 +59,9 @@ class SupportMailbox(POP3Mailbox):
|
|||||||
|
|
||||||
mail.save_attachments_in_doc(ticket.doc)
|
mail.save_attachments_in_doc(ticket.doc)
|
||||||
|
|
||||||
make(content=mail.content, sender=mail.from_email,
|
make(content=mail.content, sender=mail.from_email, subject = ticket.doc.subject,
|
||||||
doctype="Support Ticket", name=ticket.doc.name,
|
doctype="Support Ticket", name=ticket.doc.name,
|
||||||
lead = ticket.doc.lead, contact=ticket.doc.contact)
|
lead = ticket.doc.lead, contact=ticket.doc.contact, date=mail.date)
|
||||||
|
|
||||||
def send_auto_reply(self, d):
|
def send_auto_reply(self, d):
|
||||||
signature = self.email_settings.fields.get('support_signature') or ''
|
signature = self.email_settings.fields.get('support_signature') or ''
|
||||||
|
@ -33,7 +33,8 @@ 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)
|
add_sales_communication(subject or "Website Query", message, sender, sender,
|
||||||
|
mail=None, status=status)
|
||||||
|
|
||||||
# guest method, cap max writes per hour
|
# guest method, cap max writes per hour
|
||||||
if webnotes.conn.sql("""select count(*) from `tabCommunication`
|
if webnotes.conn.sql("""select count(*) from `tabCommunication`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user