mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-20 21:49:18 +00:00
[mailbox] removed separate email settings for jobs, sales, support
This commit is contained in:
@@ -155,7 +155,7 @@ def get_data():
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "doctype",
|
"type": "doctype",
|
||||||
"name": "Jobs Email Settings",
|
"name": "Email Account",
|
||||||
"description": _("Setup incoming server for jobs email id. (e.g. jobs@example.com)")
|
"description": _("Setup incoming server for jobs email id. (e.g. jobs@example.com)")
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ def get_data():
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "doctype",
|
"type": "doctype",
|
||||||
"name": "Sales Email Settings",
|
"name": "Email Account",
|
||||||
"description": _("Setup incoming server for sales email id. (e.g. sales@example.com)")
|
"description": _("Setup incoming server for sales email id. (e.g. sales@example.com)")
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -73,21 +73,6 @@ def get_data():
|
|||||||
"name": "Email Digest",
|
"name": "Email Digest",
|
||||||
"description": _("Create and manage daily, weekly and monthly email digests.")
|
"description": _("Create and manage daily, weekly and monthly email digests.")
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "doctype",
|
|
||||||
"name": "Support Email Settings",
|
|
||||||
"description": _("Setup incoming server for support email id. (e.g. support@example.com)")
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "doctype",
|
|
||||||
"name": "Sales Email Settings",
|
|
||||||
"description": _("Setup incoming server for sales email id. (e.g. sales@example.com)")
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "doctype",
|
|
||||||
"name": "Jobs Email Settings",
|
|
||||||
"description": _("Setup incoming server for jobs email id. (e.g. jobs@example.com)")
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "doctype",
|
"type": "doctype",
|
||||||
"name": "SMS Settings",
|
"name": "SMS Settings",
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ def get_data():
|
|||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"type": "doctype",
|
"type": "doctype",
|
||||||
"name": "Support Email Settings",
|
"name": "Email Account",
|
||||||
"description": _("Setup incoming server for support email id. (e.g. support@example.com)")
|
"description": _("Setup incoming server for support email id. (e.g. support@example.com)")
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -33,13 +33,6 @@ class SellingController(StockController):
|
|||||||
self.validate_max_discount()
|
self.validate_max_discount()
|
||||||
check_active_sales_items(self)
|
check_active_sales_items(self)
|
||||||
|
|
||||||
def get_sender(self, comm):
|
|
||||||
sender = None
|
|
||||||
if cint(frappe.db.get_value('Sales Email Settings', None, 'extract_emails')):
|
|
||||||
sender = frappe.db.get_value('Sales Email Settings', None, 'email_id')
|
|
||||||
|
|
||||||
return sender or comm.sender or frappe.session.user
|
|
||||||
|
|
||||||
def set_missing_values(self, for_validate=False):
|
def set_missing_values(self, for_validate=False):
|
||||||
super(SellingController, self).set_missing_values(for_validate)
|
super(SellingController, self).set_missing_values(for_validate)
|
||||||
|
|
||||||
|
|||||||
@@ -8,28 +8,16 @@ from frappe import msgprint, _, throw
|
|||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
status_map = {
|
status_map = {
|
||||||
"Contact": [
|
|
||||||
["Replied", "communication_sent"],
|
|
||||||
["Open", "communication_received"]
|
|
||||||
],
|
|
||||||
"Job Applicant": [
|
|
||||||
["Replied", "communication_sent"],
|
|
||||||
["Open", "communication_received"]
|
|
||||||
],
|
|
||||||
"Lead": [
|
"Lead": [
|
||||||
["Replied", "communication_sent"],
|
|
||||||
["Converted", "has_customer"],
|
["Converted", "has_customer"],
|
||||||
["Opportunity", "has_opportunity"],
|
["Opportunity", "has_opportunity"],
|
||||||
["Open", "communication_received"],
|
|
||||||
],
|
],
|
||||||
"Opportunity": [
|
"Opportunity": [
|
||||||
["Draft", None],
|
["Draft", None],
|
||||||
["Submitted", "eval:self.docstatus==1"],
|
["Submitted", "eval:self.docstatus==1"],
|
||||||
["Lost", "eval:self.status=='Lost'"],
|
["Lost", "eval:self.status=='Lost'"],
|
||||||
["Quotation", "has_quotation"],
|
["Quotation", "has_quotation"],
|
||||||
["Replied", "communication_sent"],
|
|
||||||
["Cancelled", "eval:self.docstatus==2"],
|
["Cancelled", "eval:self.docstatus==2"],
|
||||||
["Open", "communication_received"],
|
|
||||||
],
|
],
|
||||||
"Quotation": [
|
"Quotation": [
|
||||||
["Draft", None],
|
["Draft", None],
|
||||||
@@ -46,10 +34,6 @@ status_map = {
|
|||||||
["Stopped", "eval:self.status=='Stopped'"],
|
["Stopped", "eval:self.status=='Stopped'"],
|
||||||
["Cancelled", "eval:self.docstatus==2"],
|
["Cancelled", "eval:self.docstatus==2"],
|
||||||
],
|
],
|
||||||
"Support Ticket": [
|
|
||||||
["Replied", "communication_sent"],
|
|
||||||
["Open", "communication_received"]
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class StatusUpdater(Document):
|
class StatusUpdater(Document):
|
||||||
@@ -90,25 +74,6 @@ class StatusUpdater(Document):
|
|||||||
if update:
|
if update:
|
||||||
frappe.db.set_value(self.doctype, self.name, "status", self.status)
|
frappe.db.set_value(self.doctype, self.name, "status", self.status)
|
||||||
|
|
||||||
def on_communication(self):
|
|
||||||
if not self.get("communications"): return
|
|
||||||
self.communication_set = True
|
|
||||||
self.get("communications").sort(key=lambda d: d.creation)
|
|
||||||
self.set_status(update=True)
|
|
||||||
del self.communication_set
|
|
||||||
|
|
||||||
def communication_received(self):
|
|
||||||
if getattr(self, "communication_set", False):
|
|
||||||
last_comm = self.get("communications")
|
|
||||||
if last_comm:
|
|
||||||
return last_comm[-1].sent_or_received == "Received"
|
|
||||||
|
|
||||||
def communication_sent(self):
|
|
||||||
if getattr(self, "communication_set", False):
|
|
||||||
last_comm = self.get("communications")
|
|
||||||
if last_comm:
|
|
||||||
return last_comm[-1].sent_or_received == "Sent"
|
|
||||||
|
|
||||||
def validate_qty(self):
|
def validate_qty(self):
|
||||||
"""
|
"""
|
||||||
Validates qty at row level
|
Validates qty at row level
|
||||||
|
|||||||
@@ -38,11 +38,6 @@ doc_events = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
scheduler_events = {
|
scheduler_events = {
|
||||||
"all": [
|
|
||||||
"erpnext.support.doctype.support_ticket.get_support_mails.get_support_mails",
|
|
||||||
"erpnext.hr.doctype.job_applicant.get_job_applications.get_job_applications",
|
|
||||||
"erpnext.selling.doctype.lead.get_leads.get_leads"
|
|
||||||
],
|
|
||||||
"daily": [
|
"daily": [
|
||||||
"erpnext.controllers.recurring_document.create_recurring_documents",
|
"erpnext.controllers.recurring_document.create_recurring_documents",
|
||||||
"erpnext.stock.utils.reorder_item",
|
"erpnext.stock.utils.reorder_item",
|
||||||
@@ -57,3 +52,6 @@ scheduler_events = {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default_mail_footer = """<div style="padding: 7px; text-align: right; color: #888"><small>
|
||||||
|
<a style="color: #888" href="https://erpnext.com">Sent via ERPNext</a></div>"""
|
||||||
|
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
|
||||||
# License: GNU General Public License v3. See license.txt
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import frappe
|
|
||||||
from frappe.utils import cstr, cint
|
|
||||||
from frappe.email.receive import POP3Server
|
|
||||||
from frappe.core.doctype.communication.communication import _make
|
|
||||||
|
|
||||||
class JobsMailbox(POP3Server):
|
|
||||||
def setup(self, args=None):
|
|
||||||
self.settings = args or frappe.get_doc("Jobs Email Settings", "Jobs Email Settings")
|
|
||||||
|
|
||||||
def process_message(self, mail):
|
|
||||||
if mail.from_email == self.settings.email_id:
|
|
||||||
return
|
|
||||||
|
|
||||||
name = frappe.db.get_value("Job Applicant", {"email_id": mail.from_email},
|
|
||||||
"name")
|
|
||||||
if name:
|
|
||||||
applicant = frappe.get_doc("Job Applicant", name)
|
|
||||||
if applicant.status!="Rejected":
|
|
||||||
applicant.status = "Open"
|
|
||||||
applicant.ignore_permissions = True
|
|
||||||
applicant.save()
|
|
||||||
else:
|
|
||||||
name = (mail.from_real_name and (mail.from_real_name + " - ") or "") \
|
|
||||||
+ mail.from_email
|
|
||||||
applicant = frappe.get_doc({
|
|
||||||
"creation": mail.date,
|
|
||||||
"doctype":"Job Applicant",
|
|
||||||
"applicant_name": name,
|
|
||||||
"email_id": mail.from_email,
|
|
||||||
"status": "Open"
|
|
||||||
})
|
|
||||||
applicant.ignore_permissions = True
|
|
||||||
applicant.ignore_mandatory = True
|
|
||||||
applicant.insert()
|
|
||||||
|
|
||||||
mail.save_attachments_in_doc(applicant)
|
|
||||||
|
|
||||||
_make(content=mail.content, sender=mail.from_email, subject=mail.subject or "No Subject",
|
|
||||||
doctype="Job Applicant", name=applicant.name, sent_or_received="Received")
|
|
||||||
|
|
||||||
def get_job_applications():
|
|
||||||
if cint(frappe.db.get_value('Jobs Email Settings', None, 'extract_emails')):
|
|
||||||
JobsMailbox()
|
|
||||||
@@ -5,13 +5,9 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from erpnext.utilities.transaction_base import TransactionBase
|
from frappe.model.document import Document
|
||||||
from frappe.utils import extract_email_id
|
from frappe.utils import extract_email_id
|
||||||
|
|
||||||
class JobApplicant(TransactionBase):
|
class JobApplicant(Document):
|
||||||
|
|
||||||
def get_sender(self, comm):
|
|
||||||
return frappe.db.get_value('Jobs Email Settings',None,'email_id') or comm.sender or frappe.session.user
|
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.set_status()
|
self.set_status()
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ def execute():
|
|||||||
"Comment", "Communication", "Company", "Contact Us Settings",
|
"Comment", "Communication", "Company", "Contact Us Settings",
|
||||||
"Country", "Currency", "Currency Exchange", "Deduction Type", "Department",
|
"Country", "Currency", "Currency Exchange", "Deduction Type", "Department",
|
||||||
"Designation", "Earning Type", "Event", "Feed", "File Data", "Fiscal Year",
|
"Designation", "Earning Type", "Event", "Feed", "File Data", "Fiscal Year",
|
||||||
"HR Settings", "Industry Type", "Jobs Email Settings", "Leave Type", "Letter Head",
|
"HR Settings", "Industry Type", "Leave Type", "Letter Head",
|
||||||
"Mode of Payment", "Module Def", "Naming Series", "POS Setting", "Print Heading",
|
"Mode of Payment", "Module Def", "Naming Series", "POS Setting", "Print Heading",
|
||||||
"Report", "Role", "Sales Email Settings", "Selling Settings", "Stock Settings", "Supplier Type", "UOM"):
|
"Report", "Role", "Selling Settings", "Stock Settings", "Supplier Type", "UOM"):
|
||||||
try:
|
try:
|
||||||
frappe.reset_perms(doctype)
|
frappe.reset_perms(doctype)
|
||||||
except:
|
except:
|
||||||
|
|||||||
@@ -5,6 +5,16 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
|
print "WARNING!!!! Email Settings not migrated. Please setup your email again."
|
||||||
|
|
||||||
|
# this will happen if you are migrating very old accounts
|
||||||
|
# comment out this line below and remember to create new Email Accounts
|
||||||
|
# for incoming and outgoing mails
|
||||||
|
raise Exception
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
frappe.reload_doc("core", "doctype", "outgoing_email_settings")
|
frappe.reload_doc("core", "doctype", "outgoing_email_settings")
|
||||||
frappe.reload_doc("support", "doctype", "support_email_settings")
|
frappe.reload_doc("support", "doctype", "support_email_settings")
|
||||||
|
|
||||||
@@ -12,7 +22,6 @@ def execute():
|
|||||||
map_outgoing_email_settings(email_settings)
|
map_outgoing_email_settings(email_settings)
|
||||||
map_support_email_settings(email_settings)
|
map_support_email_settings(email_settings)
|
||||||
|
|
||||||
frappe.delete_doc("DocType", "Email Settings")
|
|
||||||
|
|
||||||
def map_outgoing_email_settings(email_settings):
|
def map_outgoing_email_settings(email_settings):
|
||||||
outgoing_email_settings = frappe.get_doc("Outgoing Email Settings")
|
outgoing_email_settings = frappe.get_doc("Outgoing Email Settings")
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import frappe
|
|||||||
from erpnext.setup.install import default_mail_footer
|
from erpnext.setup.install import default_mail_footer
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
|
return
|
||||||
mail_footer = frappe.db.get_default('mail_footer') or ''
|
mail_footer = frappe.db.get_default('mail_footer') or ''
|
||||||
mail_footer += default_mail_footer
|
mail_footer += default_mail_footer
|
||||||
frappe.db.set_value("Outgoing Email Settings", "Outgoing Email Settings", "footer", mail_footer)
|
frappe.db.set_value("Outgoing Email Settings", "Outgoing Email Settings", "footer", mail_footer)
|
||||||
|
|||||||
73
erpnext/patches/v4_4/make_email_accounts.py
Normal file
73
erpnext/patches/v4_4/make_email_accounts.py
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
frappe.reload_doc("email", "doctype", "email_account")
|
||||||
|
|
||||||
|
# outgoing
|
||||||
|
outgoing = frappe.get_doc("Outgoing Email Settings")
|
||||||
|
account = frappe.new_doc("Email Account")
|
||||||
|
mapping = {
|
||||||
|
"email_id": "mail_login",
|
||||||
|
"password": "mail_password",
|
||||||
|
"footer": "footer",
|
||||||
|
"smtp_server": "mail_server",
|
||||||
|
"smtp_port": "mail_port",
|
||||||
|
"use_tls": "use_ssl"
|
||||||
|
}
|
||||||
|
|
||||||
|
for target_fieldname, source_fieldname in mapping.iteritems():
|
||||||
|
account.set(target_fieldname, outgoing.get(source_fieldname))
|
||||||
|
|
||||||
|
account.enable_outgoing = 1
|
||||||
|
account.enable_incoming = 0
|
||||||
|
account.is_global = 1
|
||||||
|
|
||||||
|
account.insert()
|
||||||
|
|
||||||
|
# support
|
||||||
|
support = frappe.get_doc("Support Email Settings")
|
||||||
|
account = frappe.new_doc("Email Account")
|
||||||
|
mapping = {
|
||||||
|
"enable_incoming": "sync_support_mails",
|
||||||
|
"email_id": "mail_login",
|
||||||
|
"password": "mail_password",
|
||||||
|
"pop3_server": "mail_server",
|
||||||
|
"use_ssl": "use_ssl",
|
||||||
|
"signature": "support_signature",
|
||||||
|
"enable_auto_reply": "send_autoreply",
|
||||||
|
"auto_reply_message": "support_autoreply"
|
||||||
|
}
|
||||||
|
|
||||||
|
for target_fieldname, source_fieldname in mapping.iteritems():
|
||||||
|
account.set(target_fieldname, support.get(source_fieldname))
|
||||||
|
|
||||||
|
account.enable_outgoing = 0
|
||||||
|
account.is_global = 1
|
||||||
|
|
||||||
|
account.insert()
|
||||||
|
|
||||||
|
# sales, jobs
|
||||||
|
for doctype in ("Sales Email Settings", "Jobs Email Settings"):
|
||||||
|
source = frappe.get_doc(doctype)
|
||||||
|
account = frappe.new_doc("Email Account")
|
||||||
|
mapping = {
|
||||||
|
"enable_incoming": "extract_emails",
|
||||||
|
"email_id": "username",
|
||||||
|
"password": "password",
|
||||||
|
"pop3_server": "host",
|
||||||
|
"use_ssl": "use_ssl",
|
||||||
|
}
|
||||||
|
|
||||||
|
for target_fieldname, source_fieldname in mapping.iteritems():
|
||||||
|
account.set(target_fieldname, source.get(source_fieldname))
|
||||||
|
|
||||||
|
account.enable_outgoing = 0
|
||||||
|
account.is_global = 1
|
||||||
|
account.append_to = "Lead" if doctype=="Sales Email Settings" else "Job Applicant"
|
||||||
|
|
||||||
|
account.insert()
|
||||||
|
|
||||||
|
for doctype in ("Outgoing Email Settings", "Support Email Settings",
|
||||||
|
"Sales Email Settings", "Jobs Email Settings"):
|
||||||
|
frappe.delete_doc("DocType", doctype)
|
||||||
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
|
||||||
# License: GNU General Public License v3. See license.txt
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import frappe
|
|
||||||
from frappe.utils import cstr, cint
|
|
||||||
from frappe.email.receive import POP3Server
|
|
||||||
from frappe.core.doctype.communication.communication import _make
|
|
||||||
|
|
||||||
def add_sales_communication(subject, content, sender, real_name, mail=None,
|
|
||||||
status="Open", date=None):
|
|
||||||
lead_name = frappe.db.get_value("Lead", {"email_id": sender})
|
|
||||||
contact_name = frappe.db.get_value("Contact", {"email_id": sender})
|
|
||||||
|
|
||||||
if not (lead_name or contact_name):
|
|
||||||
# none, create a new Lead
|
|
||||||
lead = frappe.get_doc({
|
|
||||||
"doctype":"Lead",
|
|
||||||
"lead_name": real_name or sender,
|
|
||||||
"email_id": sender,
|
|
||||||
"status": status,
|
|
||||||
"source": "Email"
|
|
||||||
})
|
|
||||||
lead.ignore_permissions = True
|
|
||||||
lead.ignore_mandatory = True
|
|
||||||
lead.insert()
|
|
||||||
lead_name = lead.name
|
|
||||||
|
|
||||||
parent_doctype = "Contact" if contact_name else "Lead"
|
|
||||||
parent_name = contact_name or lead_name
|
|
||||||
|
|
||||||
message = _make(content=content, sender=sender, subject=subject,
|
|
||||||
doctype = parent_doctype, name = parent_name, date=date, sent_or_received="Received")
|
|
||||||
|
|
||||||
if mail:
|
|
||||||
# save attachments to parent if from mail
|
|
||||||
doc = frappe.get_doc(parent_doctype, parent_name)
|
|
||||||
mail.save_attachments_in_doc(doc)
|
|
||||||
|
|
||||||
class SalesMailbox(POP3Server):
|
|
||||||
def setup(self, args=None):
|
|
||||||
self.settings = args or frappe.get_doc("Sales Email Settings", "Sales Email Settings")
|
|
||||||
|
|
||||||
def process_message(self, mail):
|
|
||||||
if mail.from_email == self.settings.email_id:
|
|
||||||
return
|
|
||||||
|
|
||||||
add_sales_communication(mail.subject, mail.content, mail.from_email,
|
|
||||||
mail.from_real_name, mail=mail, date=mail.date)
|
|
||||||
|
|
||||||
def get_leads():
|
|
||||||
if cint(frappe.db.get_value('Sales Email Settings', None, 'extract_emails')):
|
|
||||||
SalesMailbox()
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Settings to extract job applications via email (POP).
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
|
||||||
// License: GNU General Public License v3. See license.txt
|
|
||||||
|
|
||||||
// For license information, please see license.txt
|
|
||||||
|
|
||||||
cur_frm.cscript = {
|
|
||||||
refresh: function(doc) {
|
|
||||||
cur_frm.set_intro("");
|
|
||||||
if(doc.extract_emails) {
|
|
||||||
cur_frm.set_intro(__("Active: Will extract emails from ") + doc.email_id);
|
|
||||||
} else {
|
|
||||||
cur_frm.set_intro(__("Not Active"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
{
|
|
||||||
"creation": "2013-01-15 16:50:01.000000",
|
|
||||||
"description": "Email settings for jobs email id \"jobs@example.com\"",
|
|
||||||
"docstatus": 0,
|
|
||||||
"doctype": "DocType",
|
|
||||||
"fields": [
|
|
||||||
{
|
|
||||||
"description": "Settings to extract Job Applicants from a mailbox e.g. \"jobs@example.com\"",
|
|
||||||
"fieldname": "pop3_mail_settings",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"label": "POP3 Mail Settings",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Check to activate",
|
|
||||||
"fieldname": "extract_emails",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"label": "Extract Emails",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Email Id where a job applicant will email e.g. \"jobs@example.com\"",
|
|
||||||
"fieldname": "email_id",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"label": "Email Id",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "POP3 server e.g. (pop.gmail.com)",
|
|
||||||
"fieldname": "host",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"label": "Host",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "use_ssl",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"label": "Use SSL",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "username",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"label": "Username",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "password",
|
|
||||||
"fieldtype": "Password",
|
|
||||||
"label": "Password",
|
|
||||||
"permlevel": 0
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"icon": "icon-cog",
|
|
||||||
"idx": 1,
|
|
||||||
"issingle": 1,
|
|
||||||
"modified": "2013-12-20 19:23:16.000000",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"module": "Setup",
|
|
||||||
"name": "Jobs Email Settings",
|
|
||||||
"owner": "Administrator",
|
|
||||||
"permissions": [
|
|
||||||
{
|
|
||||||
"create": 1,
|
|
||||||
"email": 1,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"read": 1,
|
|
||||||
"role": "System Manager",
|
|
||||||
"write": 1
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
|
||||||
# License: GNU General Public License v3. See license.txt
|
|
||||||
|
|
||||||
# For license information, please see license.txt
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import frappe
|
|
||||||
from frappe import _
|
|
||||||
from frappe.utils import cint
|
|
||||||
|
|
||||||
from frappe.model.document import Document
|
|
||||||
|
|
||||||
class JobsEmailSettings(Document):
|
|
||||||
|
|
||||||
def validate(self):
|
|
||||||
if cint(self.extract_emails) and not (self.email_id and self.host and \
|
|
||||||
self.username and self.password):
|
|
||||||
|
|
||||||
frappe.throw(_("""Host, Email and Password required if emails are to be pulled"""))
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Settings for creating new Communication, Leads from sales inbox like "sales@example.com" via POP3.
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
|
||||||
// License: GNU General Public License v3. See license.txt
|
|
||||||
|
|
||||||
// For license information, please see license.txt
|
|
||||||
|
|
||||||
cur_frm.cscript = {
|
|
||||||
refresh: function(doc) {
|
|
||||||
cur_frm.set_intro("");
|
|
||||||
if(doc.extract_emails) {
|
|
||||||
cur_frm.set_intro(__("Active: Will extract emails from ") + doc.email_id);
|
|
||||||
} else {
|
|
||||||
cur_frm.set_intro(__("Not Active"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
{
|
|
||||||
"creation": "2013-01-16 10:25:26.000000",
|
|
||||||
"description": "Email settings to extract Leads from sales email id e.g. \"sales@example.com\"",
|
|
||||||
"docstatus": 0,
|
|
||||||
"doctype": "DocType",
|
|
||||||
"fields": [
|
|
||||||
{
|
|
||||||
"description": "Email settings to extract Leads from sales email id e.g. \"sales@example.com\"",
|
|
||||||
"fieldname": "pop3_mail_settings",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"label": "POP3 Mail Settings",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Check to activate",
|
|
||||||
"fieldname": "extract_emails",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"label": "Extract Emails",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Email Id where a job applicant will email e.g. \"jobs@example.com\"",
|
|
||||||
"fieldname": "email_id",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"label": "Email Id",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "POP3 server e.g. (pop.gmail.com)",
|
|
||||||
"fieldname": "host",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"label": "Host",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "use_ssl",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"label": "Use SSL",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "username",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"label": "Username",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "password",
|
|
||||||
"fieldtype": "Password",
|
|
||||||
"label": "Password",
|
|
||||||
"permlevel": 0
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"icon": "icon-cog",
|
|
||||||
"idx": 1,
|
|
||||||
"issingle": 1,
|
|
||||||
"modified": "2013-12-20 19:21:38.000000",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"module": "Setup",
|
|
||||||
"name": "Sales Email Settings",
|
|
||||||
"owner": "Administrator",
|
|
||||||
"permissions": [
|
|
||||||
{
|
|
||||||
"create": 1,
|
|
||||||
"email": 1,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"read": 1,
|
|
||||||
"role": "System Manager",
|
|
||||||
"write": 1
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
|
||||||
# License: GNU General Public License v3. See license.txt
|
|
||||||
|
|
||||||
# For license information, please see license.txt
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import frappe
|
|
||||||
from frappe import _
|
|
||||||
from frappe.utils import cint
|
|
||||||
|
|
||||||
from frappe.model.document import Document
|
|
||||||
|
|
||||||
class SalesEmailSettings(Document):
|
|
||||||
|
|
||||||
def validate(self):
|
|
||||||
if cint(self.extract_emails) and not (self.email_id and self.host and \
|
|
||||||
self.username and self.password):
|
|
||||||
|
|
||||||
frappe.msgprint(_("""Host, Email and Password required if emails are to be pulled"""),
|
|
||||||
raise_exception=True)
|
|
||||||
@@ -52,6 +52,3 @@ def set_single_defaults():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
frappe.db.set_default("date_format", "dd-mm-yyyy")
|
frappe.db.set_default("date_format", "dd-mm-yyyy")
|
||||||
|
|
||||||
frappe.db.set_value("Outgoing Email Settings", "Outgoing Email Settings", "footer",
|
|
||||||
default_mail_footer)
|
|
||||||
|
|||||||
@@ -192,9 +192,6 @@ class SerialNo(StockController):
|
|||||||
self.set_sales_details(last_sle.get("delivery_sle"))
|
self.set_sales_details(last_sle.get("delivery_sle"))
|
||||||
self.set_maintenance_status()
|
self.set_maintenance_status()
|
||||||
|
|
||||||
def on_communication(self):
|
|
||||||
return
|
|
||||||
|
|
||||||
def process_serial_no(sle):
|
def process_serial_no(sle):
|
||||||
item_det = get_item_details(sle.item_code)
|
item_det = get_item_details(sle.item_code)
|
||||||
validate_serial_no(sle, item_det)
|
validate_serial_no(sle, item_det)
|
||||||
|
|||||||
@@ -1,92 +0,0 @@
|
|||||||
{
|
|
||||||
"allow_copy": 1,
|
|
||||||
"creation": "2014-03-03 19:48:46.000000",
|
|
||||||
"description": "Email Settings for Outgoing and Incoming Emails.",
|
|
||||||
"docstatus": 0,
|
|
||||||
"doctype": "DocType",
|
|
||||||
"fields": [
|
|
||||||
{
|
|
||||||
"description": "Check this to pull emails from your mailbox",
|
|
||||||
"fieldname": "sync_support_mails",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"label": "Sync Support Mails",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Your support email id - must be a valid email - this is where your emails will come!",
|
|
||||||
"fieldname": "support_email",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"label": "Support Email",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "POP3 mail server (e.g. pop.gmail.com)",
|
|
||||||
"fieldname": "mail_server",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"label": "POP3 Mail Server",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "use_ssl",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"label": "Use SSL",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "mail_login",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"label": "User Name",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "mail_password",
|
|
||||||
"fieldtype": "Password",
|
|
||||||
"label": "Support Password",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "cb1",
|
|
||||||
"fieldtype": "Column Break",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Signature to be appended at the end of every email",
|
|
||||||
"fieldname": "support_signature",
|
|
||||||
"fieldtype": "Text",
|
|
||||||
"label": "Signature",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"default": "1",
|
|
||||||
"fieldname": "send_autoreply",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"label": "Send Autoreply",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Autoreply when a new mail is received",
|
|
||||||
"fieldname": "support_autoreply",
|
|
||||||
"fieldtype": "Text",
|
|
||||||
"label": "Custom Autoreply Message",
|
|
||||||
"permlevel": 0
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"icon": "icon-cog",
|
|
||||||
"idx": 1,
|
|
||||||
"in_create": 1,
|
|
||||||
"issingle": 1,
|
|
||||||
"modified": "2014-03-03 20:20:34.000000",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"module": "Support",
|
|
||||||
"name": "Support Email Settings",
|
|
||||||
"owner": "Administrator",
|
|
||||||
"permissions": [
|
|
||||||
{
|
|
||||||
"create": 1,
|
|
||||||
"permlevel": 0,
|
|
||||||
"read": 1,
|
|
||||||
"role": "System Manager",
|
|
||||||
"write": 1
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
|
||||||
# MIT License. See license.txt
|
|
||||||
|
|
||||||
# For license information, please see license.txt
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import frappe
|
|
||||||
from frappe import _
|
|
||||||
from frappe.utils import cint
|
|
||||||
from frappe.model.document import Document
|
|
||||||
from frappe.email.receive import POP3Server
|
|
||||||
import _socket, poplib
|
|
||||||
|
|
||||||
class SupportEmailSettings(Document):
|
|
||||||
|
|
||||||
def validate(self):
|
|
||||||
"""
|
|
||||||
Checks support ticket email settings
|
|
||||||
"""
|
|
||||||
if cint(self.sync_support_mails) and self.mail_server and not frappe.local.flags.in_patch:
|
|
||||||
inc_email = frappe._dict(self.as_dict())
|
|
||||||
# inc_email.encode()
|
|
||||||
inc_email.host = self.mail_server
|
|
||||||
inc_email.use_ssl = self.use_ssl
|
|
||||||
try:
|
|
||||||
err_msg = _('User Name or Support Password missing. Please enter and try again.')
|
|
||||||
if not (self.mail_login and self.mail_password):
|
|
||||||
raise AttributeError, err_msg
|
|
||||||
inc_email.username = self.mail_login
|
|
||||||
inc_email.password = self.mail_password
|
|
||||||
except AttributeError, e:
|
|
||||||
frappe.msgprint(err_msg)
|
|
||||||
raise
|
|
||||||
|
|
||||||
pop_mb = POP3Server(inc_email)
|
|
||||||
|
|
||||||
try:
|
|
||||||
pop_mb.connect()
|
|
||||||
except _socket.error, e:
|
|
||||||
# Invalid mail server -- due to refusing connection
|
|
||||||
frappe.msgprint(_('Invalid Mail Server. Please rectify and try again.'))
|
|
||||||
raise
|
|
||||||
except poplib.error_proto, e:
|
|
||||||
frappe.msgprint(_('Invalid User Name or Support Password. Please rectify and try again.'))
|
|
||||||
raise
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
|
||||||
# License: GNU General Public License v3. See license.txt
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import frappe
|
|
||||||
from frappe.utils import cstr, cint, decode_dict, today
|
|
||||||
from frappe.email import sendmail
|
|
||||||
from frappe.email.receive import POP3Server
|
|
||||||
from frappe.core.doctype.communication.communication import _make
|
|
||||||
|
|
||||||
class SupportMailbox(POP3Server):
|
|
||||||
def setup(self, args=None):
|
|
||||||
self.email_settings = frappe.get_doc("Support Email Settings", "Support Email Settings")
|
|
||||||
self.settings = args or frappe._dict({
|
|
||||||
"use_ssl": self.email_settings.use_ssl,
|
|
||||||
"host": self.email_settings.mail_server,
|
|
||||||
"username": self.email_settings.mail_login,
|
|
||||||
"password": self.email_settings.mail_password
|
|
||||||
})
|
|
||||||
|
|
||||||
def process_message(self, mail):
|
|
||||||
if mail.from_email == self.email_settings.get('support_email'):
|
|
||||||
return
|
|
||||||
thread_id = mail.get_thread_id()
|
|
||||||
new_ticket = False
|
|
||||||
|
|
||||||
if not (thread_id and frappe.db.exists("Support Ticket", thread_id)):
|
|
||||||
new_ticket = True
|
|
||||||
|
|
||||||
ticket = add_support_communication(mail.subject, mail.content, mail.from_email,
|
|
||||||
docname=None if new_ticket else thread_id, mail=mail)
|
|
||||||
|
|
||||||
if new_ticket and cint(self.email_settings.send_autoreply) and \
|
|
||||||
"mailer-daemon" not in mail.from_email.lower():
|
|
||||||
self.send_auto_reply(ticket)
|
|
||||||
|
|
||||||
def send_auto_reply(self, d):
|
|
||||||
signature = self.email_settings.get('support_signature') or ''
|
|
||||||
response = self.email_settings.get('support_autoreply') or ("""
|
|
||||||
A new Ticket has been raised for your query. If you have any additional information, please
|
|
||||||
reply back to this mail.
|
|
||||||
|
|
||||||
### We will get back to you as soon as possible
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Original Query:
|
|
||||||
|
|
||||||
""" + d.description + "\n\n---\n\n" + cstr(signature))
|
|
||||||
|
|
||||||
sendmail(\
|
|
||||||
recipients = [cstr(d.raised_by)], \
|
|
||||||
sender = cstr(self.email_settings.get('support_email')), \
|
|
||||||
subject = '['+cstr(d.name)+'] ' + cstr(d.subject), \
|
|
||||||
msg = cstr(response))
|
|
||||||
|
|
||||||
def get_support_mails():
|
|
||||||
if cint(frappe.db.get_value('Support Email Settings', None, 'sync_support_mails')):
|
|
||||||
SupportMailbox()
|
|
||||||
|
|
||||||
def add_support_communication(subject, content, sender, docname=None, mail=None):
|
|
||||||
if docname:
|
|
||||||
ticket = frappe.get_doc("Support Ticket", docname)
|
|
||||||
ticket.status = 'Open'
|
|
||||||
ticket.ignore_permissions = True
|
|
||||||
ticket.save()
|
|
||||||
else:
|
|
||||||
ticket = frappe.get_doc(decode_dict({
|
|
||||||
"doctype":"Support Ticket",
|
|
||||||
"description": content,
|
|
||||||
"subject": subject,
|
|
||||||
"raised_by": sender,
|
|
||||||
"content_type": mail.content_type if mail else None,
|
|
||||||
"status": "Open",
|
|
||||||
}))
|
|
||||||
ticket.ignore_permissions = True
|
|
||||||
ticket.ignore_mandatory = True
|
|
||||||
ticket.insert()
|
|
||||||
|
|
||||||
_make(content=content, sender=sender, subject = subject,
|
|
||||||
doctype="Support Ticket", name=ticket.name,
|
|
||||||
date=mail.date if mail else today(), sent_or_received="Received")
|
|
||||||
|
|
||||||
if mail:
|
|
||||||
mail.save_attachments_in_doc(ticket)
|
|
||||||
|
|
||||||
return ticket
|
|
||||||
@@ -5,26 +5,13 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
from erpnext.utilities.transaction_base import TransactionBase
|
from frappe.model.document import Document
|
||||||
from frappe.utils import now, extract_email_id
|
from frappe.utils import now
|
||||||
|
|
||||||
class SupportTicket(TransactionBase):
|
class SupportTicket(Document):
|
||||||
def get_feed(self):
|
def get_feed(self):
|
||||||
return "{0}: {1}".format(_(self.status, self.subject))
|
return "{0}: {1}".format(_(self.status, self.subject))
|
||||||
|
|
||||||
def get_sender(self, comm):
|
|
||||||
return frappe.db.get_value('Support Email Settings',None,'support_email')
|
|
||||||
|
|
||||||
def get_subject(self, comm):
|
|
||||||
return '[' + self.name + '] ' + (comm.subject or 'No Subject Specified')
|
|
||||||
|
|
||||||
def get_content(self, comm):
|
|
||||||
signature = frappe.db.get_value('Support Email Settings',None,'support_signature')
|
|
||||||
content = comm.content
|
|
||||||
if signature:
|
|
||||||
content += '<p>' + signature + '</p>'
|
|
||||||
return content
|
|
||||||
|
|
||||||
def get_portal_page(self):
|
def get_portal_page(self):
|
||||||
return "ticket"
|
return "ticket"
|
||||||
|
|
||||||
|
|||||||
@@ -7,19 +7,14 @@ import frappe
|
|||||||
@frappe.whitelist(allow_guest=True)
|
@frappe.whitelist(allow_guest=True)
|
||||||
def send_message(subject="Website Query", message="", sender="", status="Open"):
|
def send_message(subject="Website Query", message="", sender="", status="Open"):
|
||||||
from frappe.templates.pages.contact import send_message as website_send_message
|
from frappe.templates.pages.contact import send_message as website_send_message
|
||||||
res = website_send_message(subject, message, sender)
|
|
||||||
|
|
||||||
if not res:
|
website_send_message(subject, message, sender)
|
||||||
return
|
|
||||||
|
|
||||||
if subject=="Support":
|
comm = frappe.get_doc({
|
||||||
# create support ticket
|
"doctype":"Communication",
|
||||||
from erpnext.support.doctype.support_ticket.get_support_mails import add_support_communication
|
"subject": subject,
|
||||||
add_support_communication(subject, message, sender, mail=None)
|
"content": message,
|
||||||
else:
|
"sender": sender,
|
||||||
# make lead / communication
|
"sent_or_received": "Received"
|
||||||
from erpnext.selling.doctype.lead.get_leads import add_sales_communication
|
})
|
||||||
add_sales_communication(subject or "Website Query", message, sender, sender,
|
comm.insert(ignore_permissions=True)
|
||||||
mail=None, status=status)
|
|
||||||
|
|
||||||
return res
|
|
||||||
|
|||||||
Reference in New Issue
Block a user