mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-29 18:04:46 +00:00
Merge branch 'master' of github.com:webnotes/erpnext
This commit is contained in:
@@ -47,7 +47,7 @@ feed_dict = {
|
|||||||
# Support
|
# Support
|
||||||
'Customer Issue': ['[%(status)s] %(description)s by %(customer_name)s', '#000080'],
|
'Customer Issue': ['[%(status)s] %(description)s by %(customer_name)s', '#000080'],
|
||||||
'Maintenance Visit':['To %(customer_name)s', '#4169E1'],
|
'Maintenance Visit':['To %(customer_name)s', '#4169E1'],
|
||||||
'Support Ticket': ['[%(status)s] %(subject)s', '#000080'],
|
'Support Ticket': ["[%(status)s] %(subject)s", '#000080'],
|
||||||
|
|
||||||
# Website
|
# Website
|
||||||
'Web Page': ['%(title)s', '#000080'],
|
'Web Page': ['%(title)s', '#000080'],
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ def add_user(args):
|
|||||||
# erpnext-saas
|
# erpnext-saas
|
||||||
if cint(webnotes.conn.get_value('Control Panel', None, 'sync_with_gateway')):
|
if cint(webnotes.conn.get_value('Control Panel', None, 'sync_with_gateway')):
|
||||||
from server_tools.gateway_utils import add_user_gateway
|
from server_tools.gateway_utils import add_user_gateway
|
||||||
add_user_gateway(args['user'])
|
add_user_gateway(args)
|
||||||
|
|
||||||
add_profile(args)
|
add_profile(args)
|
||||||
|
|
||||||
|
|||||||
@@ -282,7 +282,8 @@ class DocType:
|
|||||||
Returns start and end date depending on the frequency of email digest
|
Returns start and end date depending on the frequency of email digest
|
||||||
"""
|
"""
|
||||||
from datetime import datetime, date, timedelta
|
from datetime import datetime, date, timedelta
|
||||||
today = datetime.now().date()
|
from webnotes.utils import now_datetime
|
||||||
|
today = now_datetime().date()
|
||||||
year, month, day = today.year, today.month, today.day
|
year, month, day = today.year, today.month, today.day
|
||||||
|
|
||||||
if self.doc.frequency == 'Daily':
|
if self.doc.frequency == 'Daily':
|
||||||
@@ -409,6 +410,7 @@ class DocType:
|
|||||||
|
|
||||||
from webnotes.utils.email_lib import sendmail
|
from webnotes.utils.email_lib import sendmail
|
||||||
try:
|
try:
|
||||||
|
#webnotes.msgprint('in send')
|
||||||
sendmail(
|
sendmail(
|
||||||
recipients=recipient_list,
|
recipients=recipient_list,
|
||||||
sender='notifications+email_digest@erpnext.com',
|
sender='notifications+email_digest@erpnext.com',
|
||||||
@@ -419,64 +421,22 @@ class DocType:
|
|||||||
)
|
)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
webnotes.msgprint('There was a problem in sending your email. Please contact support@erpnext.com')
|
webnotes.msgprint('There was a problem in sending your email. Please contact support@erpnext.com')
|
||||||
#webnotes.errprint(webnotes.getTraceback())
|
webnotes.errprint(webnotes.getTraceback())
|
||||||
|
|
||||||
|
|
||||||
def get_next_sending(self):
|
def get_next_sending(self):
|
||||||
"""
|
|
||||||
|
|
||||||
"""
|
|
||||||
# Get TimeZone
|
|
||||||
# Get System TimeZone
|
|
||||||
import time
|
|
||||||
from pytz import timezone
|
|
||||||
import datetime
|
import datetime
|
||||||
import webnotes.defs
|
|
||||||
cp = webnotes.model.doc.Document('Control Panel','Control Panel')
|
|
||||||
app_tz = timezone(cp.time_zone)
|
|
||||||
server_tz = timezone(getattr(webnotes.defs, 'system_timezone'))
|
|
||||||
|
|
||||||
start_date, end_date = self.get_start_end_dates()
|
start_date, end_date = self.get_start_end_dates()
|
||||||
|
|
||||||
new_date = end_date + datetime.timedelta(days=1)
|
send_date = end_date + datetime.timedelta(days=1)
|
||||||
new_time = datetime.time(hour=6)
|
|
||||||
|
|
||||||
naive_dt = datetime.datetime.combine(new_date, new_time)
|
|
||||||
app_dt = app_tz.localize(naive_dt)
|
|
||||||
server_dt = server_tz.normalize(app_dt.astimezone(server_tz))
|
|
||||||
|
|
||||||
res = {
|
|
||||||
'app_dt': app_dt.replace(tzinfo=None),
|
|
||||||
'app_tz': app_tz,
|
|
||||||
'server_dt': server_dt.replace(tzinfo=None),
|
|
||||||
'server_tz': server_tz
|
|
||||||
}
|
|
||||||
|
|
||||||
from webnotes.utils import formatdate
|
from webnotes.utils import formatdate
|
||||||
str_date = formatdate(str(res['app_dt'].date()))
|
str_date = formatdate(str(send_date))
|
||||||
str_time = res['app_dt'].time().strftime('%I:%M')
|
|
||||||
|
|
||||||
self.doc.next_send = str_date + " at about " + str_time
|
self.doc.next_send = str_date + " at midnight"
|
||||||
|
|
||||||
return res
|
return send_date
|
||||||
|
|
||||||
|
|
||||||
def get_next_execution(self):
|
|
||||||
"""
|
|
||||||
|
|
||||||
"""
|
|
||||||
from datetime import datetime, timedelta
|
|
||||||
dt_args = self.get_next_sending()
|
|
||||||
server_dt = dt_args['server_dt']
|
|
||||||
now_dt = datetime.now(dt_args['server_tz'])
|
|
||||||
if now_dt.time() <= server_dt.time():
|
|
||||||
next_date = now_dt.date()
|
|
||||||
else:
|
|
||||||
next_date = now_dt.date() + timedelta(days=1)
|
|
||||||
|
|
||||||
next_time = server_dt.time()
|
|
||||||
|
|
||||||
return datetime.combine(next_date, next_time)
|
|
||||||
|
|
||||||
|
|
||||||
def onload(self):
|
def onload(self):
|
||||||
@@ -743,21 +703,16 @@ def send():
|
|||||||
""", as_list=1)
|
""", as_list=1)
|
||||||
|
|
||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
from datetime import datetime, timedelta
|
from webnotes.utils import now_datetime
|
||||||
now = datetime.now()
|
|
||||||
now_date = now.date()
|
|
||||||
now_time = (now + timedelta(hours=2)).time()
|
|
||||||
|
|
||||||
|
now_date = now_datetime().date()
|
||||||
|
|
||||||
for ed in edigest_list:
|
for ed in edigest_list:
|
||||||
if ed[0]:
|
if ed[0]:
|
||||||
ed_obj = get_obj('Email Digest', ed[0])
|
ed_obj = get_obj('Email Digest', ed[0])
|
||||||
ed_obj.sending = True
|
ed_obj.sending = True
|
||||||
dt_dict = ed_obj.get_next_sending()
|
send_date = ed_obj.get_next_sending()
|
||||||
send_date = dt_dict['server_dt'].date()
|
#webnotes.msgprint([ed[0], now_date, send_date])
|
||||||
send_time = dt_dict['server_dt'].time()
|
|
||||||
|
|
||||||
if (now_date == send_date):
|
if (now_date == send_date):
|
||||||
#webnotes.msgprint('sending ' + ed_obj.doc.name)
|
|
||||||
ed_obj.send()
|
ed_obj.send()
|
||||||
#else:
|
|
||||||
# webnotes.msgprint('not sending ' + ed_obj.doc.name)
|
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ class DocType:
|
|||||||
"""
|
"""
|
||||||
Update value in control panel
|
Update value in control panel
|
||||||
"""
|
"""
|
||||||
if self.doc.fields.get(key):
|
webnotes.conn.set_value('Control Panel', None, key,
|
||||||
webnotes.conn.set_value('Control Panel', None, key, self.doc.fields[key])
|
self.doc.fields.get(key))
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
"""
|
"""
|
||||||
@@ -117,19 +117,7 @@ class DocType:
|
|||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
"""
|
"""
|
||||||
Sets or cancels the event in the scheduler
|
update control panel
|
||||||
"""
|
"""
|
||||||
# update control panel
|
|
||||||
for f in ('outgoing_mail_server', 'mail_login', 'mail_password', 'auto_email_id', 'mail_port', 'use_ssl'):
|
for f in ('outgoing_mail_server', 'mail_login', 'mail_password', 'auto_email_id', 'mail_port', 'use_ssl'):
|
||||||
self.set_cp_value(f)
|
self.set_cp_value(f)
|
||||||
|
|
||||||
# setup scheduler for support emails
|
|
||||||
if cint(self.doc.sync_support_mails):
|
|
||||||
if not (self.doc.support_host and self.doc.support_username and self.doc.support_password):
|
|
||||||
webnotes.msgprint("You must give the incoming POP3 settings for support emails to activiate mailbox integration", raise_exception=1)
|
|
||||||
|
|
||||||
from webnotes.utils.scheduler import set_event
|
|
||||||
set_event('support.doctype.support_ticket.get_support_mails', 60*5, 1)
|
|
||||||
else:
|
|
||||||
from webnotes.utils.scheduler import cancel_event
|
|
||||||
cancel_event('support.doctype.support_ticket.get_support_mails')
|
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ class SupportMailbox(POP3Mailbox):
|
|||||||
st.make_response_record(content, mail.mail['From'], content_type)
|
st.make_response_record(content, mail.mail['From'], content_type)
|
||||||
webnotes.conn.set(st.doc, 'status', 'Open')
|
webnotes.conn.set(st.doc, 'status', 'Open')
|
||||||
update_feed(st.doc, 'on_update')
|
update_feed(st.doc, 'on_update')
|
||||||
|
webnotes.conn.commit()
|
||||||
# extract attachments
|
# extract attachments
|
||||||
self.save_attachments(st.doc, mail.attachments)
|
self.save_attachments(st.doc, mail.attachments)
|
||||||
return
|
return
|
||||||
@@ -99,21 +100,22 @@ class SupportMailbox(POP3Mailbox):
|
|||||||
d.naming_series = (opts and opts[0] and opts[0][0] and opts[0][0].split("\n")[0]) or 'SUP'
|
d.naming_series = (opts and opts[0] and opts[0][0] and opts[0][0].split("\n")[0]) or 'SUP'
|
||||||
try:
|
try:
|
||||||
d.save(1)
|
d.save(1)
|
||||||
|
except:
|
||||||
|
d.description = 'Unable to extract message'
|
||||||
|
d.save(1)
|
||||||
|
|
||||||
|
else:
|
||||||
# update feed
|
# update feed
|
||||||
update_feed(d, 'on_update')
|
update_feed(d, 'on_update')
|
||||||
|
|
||||||
# send auto reply
|
# send auto reply
|
||||||
self.send_auto_reply(d)
|
self.send_auto_reply(d)
|
||||||
|
|
||||||
except:
|
webnotes.conn.commit()
|
||||||
d.description = 'Unable to extract message'
|
|
||||||
d.save(1)
|
|
||||||
|
|
||||||
else:
|
|
||||||
# extract attachments
|
# extract attachments
|
||||||
self.save_attachments(d, mail.attachments)
|
self.save_attachments(d, mail.attachments)
|
||||||
|
|
||||||
|
|
||||||
def save_attachments(self, doc, attachment_list=[]):
|
def save_attachments(self, doc, attachment_list=[]):
|
||||||
"""
|
"""
|
||||||
@@ -138,9 +140,10 @@ class SupportMailbox(POP3Mailbox):
|
|||||||
"""
|
"""
|
||||||
Send auto reply to emails
|
Send auto reply to emails
|
||||||
"""
|
"""
|
||||||
signature = self.email_settings.support_signature
|
from webnotes.utils import cstr
|
||||||
|
signature = self.email_settings.fields.get('support_signature') or ''
|
||||||
|
|
||||||
response = self.email_settings.support_autoreply or ("""
|
response = self.email_settings.fields.get('support_autoreply') or ("""
|
||||||
A new Ticket has been raised for your query. If you have any additional information, please
|
A new Ticket has been raised for your query. If you have any additional information, please
|
||||||
reply back to this mail.
|
reply back to this mail.
|
||||||
|
|
||||||
@@ -148,15 +151,15 @@ We will get back to you as soon as possible
|
|||||||
|
|
||||||
[This is an automatic response]
|
[This is an automatic response]
|
||||||
|
|
||||||
""" + (signature or ''))
|
""" + cstr(signature))
|
||||||
|
|
||||||
from webnotes.utils.email_lib import sendmail
|
from webnotes.utils.email_lib import sendmail
|
||||||
|
|
||||||
sendmail(\
|
sendmail(\
|
||||||
recipients = [d.raised_by], \
|
recipients = [cstr(d.raised_by)], \
|
||||||
sender = self.email_settings.support_email, \
|
sender = cstr(self.email_settings.fields.get('support_email')), \
|
||||||
subject = '['+d.name+'] ' + cstr(d.subject), \
|
subject = '['+cstr(d.name)+'] ' + cstr(d.subject), \
|
||||||
msg = response)
|
msg = cstr(response))
|
||||||
|
|
||||||
def auto_close_tickets(self):
|
def auto_close_tickets(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user