mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-15 04:45:09 +00:00
[fix] [minor] merge conflict fixed
This commit is contained in:
@@ -16,8 +16,6 @@ import webnotes
|
||||
from webnotes.utils import get_request_site_address, cstr
|
||||
from webnotes import _
|
||||
|
||||
from backup_manager import ignore_list
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_dropbox_authorize_url():
|
||||
sess = get_dropbox_session()
|
||||
@@ -100,9 +98,7 @@ def backup_to_dropbox():
|
||||
path = get_files_path()
|
||||
for filename in os.listdir(path):
|
||||
filename = cstr(filename)
|
||||
if filename in ignore_list:
|
||||
continue
|
||||
|
||||
|
||||
found = False
|
||||
filepath = os.path.join(path, filename)
|
||||
for file_metadata in response["contents"]:
|
||||
|
||||
@@ -87,7 +87,7 @@ $.extend(cur_frm.cscript, {
|
||||
cur_frm.save();
|
||||
},
|
||||
|
||||
upload_backups_to_gdrive: function() {
|
||||
cur_frm.save();
|
||||
},
|
||||
// upload_backups_to_gdrive: function() {
|
||||
// cur_frm.save();
|
||||
// },
|
||||
});
|
||||
@@ -7,8 +7,6 @@ from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import _
|
||||
|
||||
ignore_list = []
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
@@ -39,10 +37,6 @@ def take_backups_dropbox():
|
||||
file_and_error = [" - ".join(f) for f in zip(did_not_upload, error_log)]
|
||||
error_message = ("\n".join(file_and_error) + "\n" + webnotes.getTraceback())
|
||||
webnotes.errprint(error_message)
|
||||
|
||||
if not webnotes.conn:
|
||||
webnotes.connect()
|
||||
|
||||
send_email(False, "Dropbox", error_message)
|
||||
|
||||
#backup to gdrive
|
||||
@@ -62,6 +56,7 @@ def take_backups_gdrive():
|
||||
send_email(False, "Google Drive", error_message)
|
||||
|
||||
def send_email(success, service_name, error_status=None):
|
||||
from webnotes.utils.email_lib import sendmail
|
||||
if success:
|
||||
subject = "Backup Upload Successful"
|
||||
message ="""<h3>Backup Uploaded Successfully</h3><p>Hi there, this is just to inform you
|
||||
@@ -76,7 +71,8 @@ def send_email(success, service_name, error_status=None):
|
||||
<p>Please contact your system manager for more information.</p>
|
||||
""" % (service_name, error_status)
|
||||
|
||||
# email system managers
|
||||
from webnotes.utils.email_lib import sendmail
|
||||
sendmail(webnotes.conn.get_value("Backup Manager", None, "send_notifications_to").split(","),
|
||||
subject=subject, msg=message)
|
||||
if not webnotes.conn:
|
||||
webnotes.connect()
|
||||
|
||||
recipients = webnotes.conn.get_value("Backup Manager", None, "send_notifications_to").split(",")
|
||||
sendmail(recipients, subject=subject, msg=message)
|
||||
|
||||
@@ -70,8 +70,10 @@ cur_frm.cscript.addremove_recipients = function(doc, dt, dn) {
|
||||
check.checked = 1;
|
||||
add_or_update = 'Update';
|
||||
}
|
||||
var fullname = wn.user.full_name(v.name);
|
||||
if(fullname !== v.name) v.name = fullname + " <" + v.name + ">";
|
||||
if(v.enabled==0) {
|
||||
v.name = "<span style='color: red'>" + v.name + " (disabled user)</span>"
|
||||
v.name = repl("<span style='color: red'> %(name)s (disabled user)</span>", {name: v.name});
|
||||
}
|
||||
var profile = $a($td(tab, i+1, 1), 'span', '', '', v.name);
|
||||
//profile.onclick = function() { check.checked = !check.checked; }
|
||||
|
||||
@@ -19,16 +19,16 @@ content_sequence = [
|
||||
["Selling", ["new_leads", "new_enquiries", "new_quotations", "new_sales_orders"]],
|
||||
["Stock", ["new_delivery_notes", "new_purchase_receipts", "new_stock_entries"]],
|
||||
["Support", ["new_communications", "new_support_tickets", "open_tickets"]],
|
||||
["Projects", ["new_projects"]]
|
||||
["Projects", ["new_projects"]],
|
||||
["System", ["scheduler_errors"]],
|
||||
]
|
||||
|
||||
user_specific_content = ["calendar_events", "todo_list"]
|
||||
|
||||
digest_template = """\
|
||||
<style>p.ed-indent { margin-right: 17px; }</style>
|
||||
<h2>%(digest)s</h2>
|
||||
<p style='color: grey'>%(date)s</p>
|
||||
digest_template = """<style>p.ed-indent { margin-right: 17px; }</style>
|
||||
<h2>%(name)s</h2>
|
||||
<h4>%(company)s</h4>
|
||||
<p style='color: grey'>%(date)s</p>
|
||||
<hr>
|
||||
%(with_value)s
|
||||
%(no_value)s
|
||||
@@ -53,10 +53,10 @@ class DocType(DocListController):
|
||||
|
||||
def get_profiles(self):
|
||||
"""get list of profiles"""
|
||||
import webnotes
|
||||
profile_list = webnotes.conn.sql("""
|
||||
select name, enabled from tabProfile
|
||||
where docstatus=0 and name not in ('Administrator', 'Guest')
|
||||
and user_type = "System User"
|
||||
order by enabled desc, name asc""", as_dict=1)
|
||||
|
||||
if self.doc.recipient_list:
|
||||
@@ -81,7 +81,9 @@ class DocType(DocListController):
|
||||
msg_for_this_receipient = self.get_msg_html(self.get_user_specific_content(user_id) + \
|
||||
common_msg)
|
||||
from webnotes.utils.email_lib import sendmail
|
||||
sendmail(recipients=user_id, subject="[ERPNext] " + (self.doc.frequency + " Digest"),
|
||||
sendmail(recipients=user_id,
|
||||
subject="[ERPNext] [{frequency} Digest] {name}".format(
|
||||
frequency=self.doc.frequency, name=self.doc.name),
|
||||
msg=msg_for_this_receipient)
|
||||
|
||||
def get_digest_msg(self):
|
||||
@@ -123,7 +125,7 @@ class DocType(DocListController):
|
||||
if with_value:
|
||||
with_value = "\n".join(with_value)
|
||||
else:
|
||||
with_value = "<p>There were no updates in the items selected for this digest.</p>"
|
||||
with_value = "<p>There were no updates in the items selected for this digest.</p><hr>"
|
||||
|
||||
# seperate out no value items
|
||||
no_value = [o[1] for o in out if not o[0]]
|
||||
@@ -138,7 +140,8 @@ class DocType(DocListController):
|
||||
"date": date,
|
||||
"company": self.doc.company,
|
||||
"with_value": with_value,
|
||||
"no_value": no_value or ""
|
||||
"no_value": no_value or "",
|
||||
"name": self.doc.name
|
||||
}
|
||||
|
||||
return msg
|
||||
@@ -241,7 +244,7 @@ class DocType(DocListController):
|
||||
return self.get_new_count("Lead", self.meta.get_label("new_leads"))
|
||||
|
||||
def get_new_enquiries(self):
|
||||
return self.get_new_count("Opportunity", self.meta.get_label("new_enquiries"))
|
||||
return self.get_new_count("Opportunity", self.meta.get_label("new_enquiries"), docstatus=1)
|
||||
|
||||
def get_new_quotations(self):
|
||||
return self.get_new_sum("Quotation", self.meta.get_label("new_quotations"), "grand_total")
|
||||
@@ -253,7 +256,8 @@ class DocType(DocListController):
|
||||
return self.get_new_sum("Delivery Note", self.meta.get_label("new_delivery_notes"), "grand_total")
|
||||
|
||||
def get_new_purchase_requests(self):
|
||||
return self.get_new_count("Material Request", self.meta.get_label("new_purchase_requests"))
|
||||
return self.get_new_count("Material Request",
|
||||
self.meta.get_label("new_purchase_requests"), docstatus=1)
|
||||
|
||||
def get_new_supplier_quotations(self):
|
||||
return self.get_new_sum("Supplier Quotation", self.meta.get_label("new_supplier_quotations"),
|
||||
@@ -271,13 +275,16 @@ class DocType(DocListController):
|
||||
return self.get_new_sum("Stock Entry", self.meta.get_label("new_stock_entries"), "total_amount")
|
||||
|
||||
def get_new_support_tickets(self):
|
||||
return self.get_new_count("Support Ticket", self.meta.get_label("new_support_tickets"), False)
|
||||
return self.get_new_count("Support Ticket", self.meta.get_label("new_support_tickets"),
|
||||
filter_by_company=False)
|
||||
|
||||
def get_new_communications(self):
|
||||
return self.get_new_count("Communication", self.meta.get_label("new_communications"), False)
|
||||
return self.get_new_count("Communication", self.meta.get_label("new_communications"),
|
||||
filter_by_company=False)
|
||||
|
||||
def get_new_projects(self):
|
||||
return self.get_new_count("Project", self.meta.get_label("new_projects"), False)
|
||||
return self.get_new_count("Project", self.meta.get_label("new_projects"),
|
||||
filter_by_company=False)
|
||||
|
||||
def get_calendar_events(self, user_id):
|
||||
from core.doctype.event.event import get_events
|
||||
@@ -321,22 +328,22 @@ class DocType(DocListController):
|
||||
else:
|
||||
return 0, "<p>To Do</p>"
|
||||
|
||||
def get_new_count(self, doctype, label, filter_by_company=True):
|
||||
def get_new_count(self, doctype, label, docstatus=0, filter_by_company=True):
|
||||
if filter_by_company:
|
||||
company = """and company="%s" """ % self.doc.company
|
||||
else:
|
||||
company = ""
|
||||
count = webnotes.conn.sql("""select count(*) from `tab%s`
|
||||
where docstatus < 2 %s and
|
||||
date(creation)>=%s and date(creation)<=%s""" % (doctype, company, "%s", "%s"),
|
||||
(self.from_date, self.to_date))
|
||||
where docstatus=%s %s and
|
||||
date(creation)>=%s and date(creation)<=%s""" %
|
||||
(doctype, docstatus, company, "%s", "%s"), (self.from_date, self.to_date))
|
||||
count = count and count[0][0] or 0
|
||||
|
||||
return count, self.get_html(label, None, count)
|
||||
|
||||
def get_new_sum(self, doctype, label, sum_field):
|
||||
count_sum = webnotes.conn.sql("""select count(*), sum(ifnull(`%s`, 0))
|
||||
from `tab%s` where docstatus < 2 and company = %s and
|
||||
from `tab%s` where docstatus=1 and company = %s and
|
||||
date(creation)>=%s and date(creation)<=%s""" % (sum_field, doctype, "%s",
|
||||
"%s", "%s"), (self.doc.company, self.from_date, self.to_date))
|
||||
count, total = count_sum and count_sum[0] or (0, 0)
|
||||
@@ -448,6 +455,10 @@ class DocType(DocListController):
|
||||
t for t in open_tickets])
|
||||
else:
|
||||
return 0, "No Open Tickets!"
|
||||
|
||||
def get_scheduler_errors(self):
|
||||
import webnotes.utils.scheduler
|
||||
return webnotes.utils.scheduler.get_error_report(self.from_date, self.to_date)
|
||||
|
||||
def onload(self):
|
||||
self.get_next_sending()
|
||||
@@ -466,4 +477,4 @@ def send():
|
||||
where enabled=1 and docstatus<2""", as_list=1):
|
||||
ed_obj = get_obj('Email Digest', ed[0])
|
||||
if (now_date == ed_obj.get_next_sending()):
|
||||
ed_obj.send()
|
||||
ed_obj.send()
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-02-21 14:15:31",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-05 14:36:13",
|
||||
"modified": "2013-12-16 12:37:43",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -100,11 +100,10 @@
|
||||
"label": "Add/Remove Recipients"
|
||||
},
|
||||
{
|
||||
"description": "Check all the items below that you want to send in this digest.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "select_digest_content",
|
||||
"fieldname": "accounts",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Select Digest Content"
|
||||
"label": "Accounts"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -178,7 +177,7 @@
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break_20",
|
||||
"fieldtype": "Section Break",
|
||||
"options": "Simple"
|
||||
"label": "Buying & Selling"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -234,6 +233,12 @@
|
||||
"fieldtype": "Check",
|
||||
"label": "New Sales Orders"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break_34",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Inventory & Support"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "stock_module",
|
||||
@@ -258,12 +263,6 @@
|
||||
"fieldtype": "Check",
|
||||
"label": "New Stock Entries"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break_34",
|
||||
"fieldtype": "Section Break",
|
||||
"options": "Simple"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "support_module",
|
||||
@@ -288,6 +287,12 @@
|
||||
"fieldtype": "Check",
|
||||
"label": "New Communications"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break_40",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Projects & System"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "projects_module",
|
||||
@@ -302,7 +307,25 @@
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "utilities_module",
|
||||
"fieldname": "core_module",
|
||||
"fieldtype": "Column Break",
|
||||
"label": "System"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "scheduler_errors",
|
||||
"fieldtype": "Check",
|
||||
"label": "Scheduler Failed Events"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "user_specific",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "User Specific"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "general",
|
||||
"fieldtype": "Column Break",
|
||||
"label": "General"
|
||||
},
|
||||
@@ -318,6 +341,12 @@
|
||||
"fieldtype": "Check",
|
||||
"label": "To Do List"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "stub",
|
||||
"fieldtype": "Column Break",
|
||||
"label": "Stub"
|
||||
},
|
||||
{
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
|
||||
@@ -233,8 +233,9 @@ items = [
|
||||
"route": "Report/Scheduler Log", "type": "Link", "icon": "icon-exclamation-sign" },
|
||||
]
|
||||
|
||||
@webnotes.whitelist(allow_roles=["System Manager"])
|
||||
@webnotes.whitelist()
|
||||
def get():
|
||||
webnotes.only_for("System Manager")
|
||||
for item in items:
|
||||
if item.get("type")=="Section":
|
||||
continue
|
||||
|
||||
@@ -175,7 +175,7 @@ def create_feed_and_todo():
|
||||
|
||||
def create_email_digest():
|
||||
from webnotes.profile import get_system_managers
|
||||
system_managers = get_system_managers()
|
||||
system_managers = get_system_managers(only_name=True)
|
||||
if not system_managers:
|
||||
return
|
||||
|
||||
@@ -190,10 +190,23 @@ def create_email_digest():
|
||||
})
|
||||
|
||||
for fieldname in edigest.meta.get_fieldnames({"fieldtype": "Check"}):
|
||||
edigest.doc.fields[fieldname] = 1
|
||||
if fieldname != "scheduler_errors":
|
||||
edigest.doc.fields[fieldname] = 1
|
||||
|
||||
edigest.insert()
|
||||
|
||||
|
||||
# scheduler errors digest
|
||||
edigest = webnotes.new_bean("Email Digest")
|
||||
edigest.doc.fields.update({
|
||||
"name": "Scheduler Errors",
|
||||
"company": webnotes.conn.get_default("company"),
|
||||
"frequency": "Daily",
|
||||
"recipient_list": "\n".join(system_managers),
|
||||
"scheduler_errors": 1,
|
||||
"enabled": 1
|
||||
})
|
||||
edigest.insert()
|
||||
|
||||
def get_fy_details(fy_start_date, fy_end_date):
|
||||
start_year = getdate(fy_start_date).year
|
||||
if start_year == getdate(fy_end_date).year:
|
||||
|
||||
Reference in New Issue
Block a user