Rewrote hooks for scheduler, notifications, boot, session, login, webpage webnotes/wnframework#351
This commit is contained in:
parent
30430796c7
commit
c652a6254f
@ -738,7 +738,7 @@ def manage_recurring_invoices(next_date=None, commit=True):
|
||||
notify_errors(ref_invoice, ref_wrapper.doc.owner)
|
||||
webnotes.conn.commit()
|
||||
|
||||
exception_list.append(webnotes.getTraceback())
|
||||
exception_list.append(webnotes.get_traceback())
|
||||
finally:
|
||||
if commit:
|
||||
webnotes.conn.begin()
|
||||
|
@ -29,8 +29,9 @@ feed_dict = {
|
||||
'Sales Order': ['[%(status)s] To %(customer_name)s worth %(currency)s %(grand_total_export)s', '#4169E1'],
|
||||
|
||||
# Purchase
|
||||
'Supplier': ['%(supplier_name)s, %(supplier_type)s', '#6495ED'],
|
||||
'Purchase Order': ['[%(status)s] %(name)s To %(supplier_name)s for %(currency)s %(grand_total_import)s', '#4169E1'],
|
||||
'Material Request': ['%(supplier_name)s, %(supplier_type)s', '#6495ED'],
|
||||
'Supplier': ['%(supplier_name)s, %(supplier_type)s', '#6495ED'],
|
||||
'Purchase Order': ['[%(status)s] %(name)s To %(supplier_name)s for %(currency)s %(grand_total_import)s', '#4169E1'],
|
||||
|
||||
# Stock
|
||||
'Delivery Note': ['[%(status)s] To %(customer_name)s', '#4169E1'],
|
||||
@ -89,3 +90,9 @@ def update_feed(controller, method=None):
|
||||
subject, color = feed_dict.get(doc.doctype, [None, None])
|
||||
if subject:
|
||||
make_feed('', doc.doctype, doc.name, doc.owner, subject % doc.fields, color)
|
||||
|
||||
def make_comment_feed(bean, method):
|
||||
"""add comment to feed"""
|
||||
doc = bean.doc
|
||||
make_feed('Comment', doc.comment_doctype, doc.comment_docname, doc.comment_by,
|
||||
'<i>"' + doc.comment + '"</i>', '#6B24B3')
|
@ -2,13 +2,57 @@ app_name ERPNext
|
||||
|
||||
app_include_js assets/js/erpnext.min.js
|
||||
app_include_css assets/css/erpnext.css
|
||||
web_include_js assets/js/erpnext-web.min.js
|
||||
|
||||
get_desktop_icons erpnext.manage.get_desktop_icons
|
||||
boot_session erpnext.startup.boot.boot_session
|
||||
notification_config erpnext.startup.notifications.get_notification_config
|
||||
|
||||
dump_report_map erpnext.startup.report_data_map.data_map
|
||||
update_website_context erpnext.startup.webutils.update_website_context
|
||||
|
||||
mail_footer erpnext.startup.mail_footer
|
||||
|
||||
on_session_creation erpnext.startup.event_handlers.on_session_creation
|
||||
on_logout erpnext.startup.event_handlers.on_logut
|
||||
|
||||
# Bean Events
|
||||
# -----------
|
||||
|
||||
bean_event *:on_update:erpnext.home.update_feed
|
||||
bean_event *:on_submit:erpnext.home.update_feed
|
||||
bean_event Comment:on_update:erpnext.home.make_comment_feed
|
||||
|
||||
bean_event *:on_update:webnotes.core.doctype.notification_count.notification_count.clear_doctype_notifications
|
||||
bean_event *:on_cancel:webnotes.core.doctype.notification_count.notification_count.clear_doctype_notifications
|
||||
bean_event *:on_trash:webnotes.core.doctype.notification_count.notification_count.clear_doctype_notifications
|
||||
|
||||
bean_event Stock Entry:on_update:erpnext.stock.doctype.material_request.material_request.update_completed_qty
|
||||
|
||||
standard_queries Warehouse:erpnext.stock.utils.get_warehouse_list
|
||||
standard_queries Customer:erpnext.selling.utils.get_customer_list
|
||||
|
||||
mail_footer erpnext.startup.mail_footer
|
||||
# Schedulers
|
||||
# ----------
|
||||
|
||||
#### Frequently
|
||||
|
||||
scheduler_event all:erpnext.support.doctype.support_ticket.get_support_mails.get_support_mails
|
||||
scheduler_event all:erpnext.hr.doctype.job_applicant.get_job_applications.get_job_applications
|
||||
scheduler_event all:erpnext.selling.doctype.lead.get_leads.get_leads
|
||||
scheduler_event all:webnotes.utils.email_lib.bulk.flush
|
||||
|
||||
#### Daily
|
||||
|
||||
scheduler_event daily:webnotes.core.doctype.event.event.send_event_digest
|
||||
scheduler_event daily:erpnext.setup.doctype.email_digest.email_digest.send
|
||||
scheduler_event daily:webnotes.core.doctype.notification_count.notification_count.delete_event_notification_count
|
||||
scheduler_event daily:webnotes.utils.email_lib.bulk.clear_outbox
|
||||
scheduler_event daily:erpnext.accounts.doctype.sales_invoice.sales_invoice.manage_recurring_invoices
|
||||
scheduler_event daily:erpnext.setup.doctype.backup_manager.backup_manager.take_backups_daily
|
||||
scheduler_event daily:erpnext.stock.utils.reorder_item
|
||||
scheduler_event daily:webnotes.scheduler.report_errors
|
||||
|
||||
#### Weekly
|
||||
|
||||
scheduler_event weekly:erpnext.setup.doctype.backup_manager.backup_manager.take_backups_weekly
|
||||
|
@ -138,7 +138,7 @@ def upload():
|
||||
error = True
|
||||
ret.append('Error for row (#%d) %s : %s' % (row_idx,
|
||||
len(row)>1 and row[1] or "", cstr(e)))
|
||||
webnotes.errprint(webnotes.getTraceback())
|
||||
webnotes.errprint(webnotes.get_traceback())
|
||||
|
||||
if error:
|
||||
webnotes.conn.rollback()
|
||||
|
@ -35,7 +35,7 @@ def update_file_list(doctype, singles):
|
||||
webnotes.conn.commit()
|
||||
webnotes.conn.sql("""alter table `tab%s` drop column `file_list`""" % doctype)
|
||||
except Exception, e:
|
||||
print webnotes.getTraceback()
|
||||
print webnotes.get_traceback()
|
||||
if (e.args and e.args[0]!=1054) or not e.args:
|
||||
raise
|
||||
|
||||
|
@ -127,7 +127,7 @@ $.extend(erpnext.cart, {
|
||||
render_item_row: function($cart_items, doc) {
|
||||
doc.image_html = doc.website_image ?
|
||||
'<div style="height: 120px; overflow: hidden;"><img src="' + doc.website_image + '" /></div>' :
|
||||
'{% include "app/stock/doctype/item/templates/includes/product_missing_image.html" %}';
|
||||
'{% include "stock/doctype/item/templates/includes/product_missing_image.html" %}';
|
||||
|
||||
if(doc.description === doc.item_name) doc.description = "";
|
||||
|
||||
|
@ -114,7 +114,7 @@ def backup_to_dropbox():
|
||||
upload_file_to_dropbox(filepath, "/files", dropbox_client)
|
||||
except Exception:
|
||||
did_not_upload.append(filename)
|
||||
error_log.append(webnotes.getTraceback())
|
||||
error_log.append(webnotes.get_traceback())
|
||||
|
||||
webnotes.connect()
|
||||
return did_not_upload, list(set(error_log))
|
||||
|
@ -37,7 +37,7 @@ def take_backups_dropbox():
|
||||
send_email(True, "Dropbox")
|
||||
except Exception:
|
||||
file_and_error = [" - ".join(f) for f in zip(did_not_upload, error_log)]
|
||||
error_message = ("\n".join(file_and_error) + "\n" + webnotes.getTraceback())
|
||||
error_message = ("\n".join(file_and_error) + "\n" + webnotes.get_traceback())
|
||||
webnotes.errprint(error_message)
|
||||
|
||||
if not webnotes.conn:
|
||||
@ -57,7 +57,7 @@ def take_backups_gdrive():
|
||||
send_email(True, "Google Drive")
|
||||
except Exception:
|
||||
file_and_error = [" - ".join(f) for f in zip(did_not_upload, error_log)]
|
||||
error_message = ("\n".join(file_and_error) + "\n" + webnotes.getTraceback())
|
||||
error_message = ("\n".join(file_and_error) + "\n" + webnotes.get_traceback())
|
||||
webnotes.errprint(error_message)
|
||||
send_email(False, "Google Drive", error_message)
|
||||
|
||||
|
@ -1,16 +0,0 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from erpnext.home import update_feed
|
||||
from webnotes.core.doctype.notification_count.notification_count import clear_doctype_notifications
|
||||
from erpnext.stock.doctype.material_request.material_request import update_completed_qty
|
||||
|
||||
def on_method(bean, method):
|
||||
if method in ("on_update", "on_submit"):
|
||||
update_feed(bean.controller, method)
|
||||
|
||||
if method in ("on_update", "on_cancel", "on_trash"):
|
||||
clear_doctype_notifications(bean.controller, method)
|
||||
|
||||
if bean.doc.doctype=="Stock Entry" and method in ("on_submit", "on_cancel"):
|
||||
update_completed_qty(bean.controller, method)
|
@ -47,7 +47,6 @@ def load_country_and_currency(bootinfo):
|
||||
where ifnull(enabled,0)=1""", as_dict=1, update={"doctype":":Currency"})
|
||||
|
||||
def get_letter_heads():
|
||||
"""load letter heads with startup"""
|
||||
import webnotes
|
||||
ret = webnotes.conn.sql("""select name, content from `tabLetter Head`
|
||||
where ifnull(disabled,0)=0""")
|
||||
|
@ -5,9 +5,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from erpnext.home import make_feed
|
||||
|
||||
def on_login_post_session(login_manager):
|
||||
def on_session_creation(login_manager):
|
||||
"""
|
||||
called after login
|
||||
update login_from and delete parallel sessions
|
||||
@ -63,10 +61,4 @@ def check_if_expired():
|
||||
webnotes.msgprint(msg)
|
||||
|
||||
webnotes.response['message'] = 'Account Expired'
|
||||
raise webnotes.AuthenticationError
|
||||
|
||||
def comment_added(doc):
|
||||
"""add comment to feed"""
|
||||
make_feed('Comment', doc.comment_doctype, doc.comment_docname, doc.comment_by,
|
||||
'<i>"' + doc.comment + '"</i>', '#6B24B3')
|
||||
|
||||
raise webnotes.AuthenticationError
|
||||
|
@ -1,74 +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
|
||||
"""will be called by scheduler"""
|
||||
|
||||
import webnotes
|
||||
from webnotes.utils import scheduler
|
||||
|
||||
def execute_all():
|
||||
"""
|
||||
* get support email
|
||||
* recurring invoice
|
||||
"""
|
||||
# pull emails
|
||||
from erpnext.support.doctype.support_ticket.get_support_mails import get_support_mails
|
||||
run_fn(get_support_mails)
|
||||
|
||||
from erpnext.hr.doctype.job_applicant.get_job_applications import get_job_applications
|
||||
run_fn(get_job_applications)
|
||||
|
||||
from erpnext.selling.doctype.lead.get_leads import get_leads
|
||||
run_fn(get_leads)
|
||||
|
||||
from webnotes.utils.email_lib.bulk import flush
|
||||
run_fn(flush)
|
||||
|
||||
def execute_daily():
|
||||
# event reminders
|
||||
from webnotes.core.doctype.event.event import send_event_digest
|
||||
run_fn(send_event_digest)
|
||||
|
||||
# clear daily event notifications
|
||||
from webnotes.core.doctype.notification_count.notification_count import delete_notification_count_for
|
||||
delete_notification_count_for("Event")
|
||||
|
||||
# email digest
|
||||
from erpnext.setup.doctype.email_digest.email_digest import send
|
||||
run_fn(send)
|
||||
|
||||
# run recurring invoices
|
||||
from erpnext.accounts.doctype.sales_invoice.sales_invoice import manage_recurring_invoices
|
||||
run_fn(manage_recurring_invoices)
|
||||
|
||||
# send bulk emails
|
||||
from webnotes.utils.email_lib.bulk import clear_outbox
|
||||
run_fn(clear_outbox)
|
||||
|
||||
# daily backup
|
||||
from erpnext.setup.doctype.backup_manager.backup_manager import take_backups_daily
|
||||
run_fn(take_backups_daily)
|
||||
|
||||
# check reorder level
|
||||
from erpnext.stock.utils import reorder_item
|
||||
run_fn(reorder_item)
|
||||
|
||||
# scheduler error
|
||||
scheduler.report_errors()
|
||||
|
||||
def execute_weekly():
|
||||
from erpnext.setup.doctype.backup_manager.backup_manager import take_backups_weekly
|
||||
run_fn(take_backups_weekly)
|
||||
|
||||
def execute_monthly():
|
||||
pass
|
||||
|
||||
def execute_hourly():
|
||||
pass
|
||||
|
||||
def run_fn(fn):
|
||||
try:
|
||||
fn()
|
||||
except Exception, e:
|
||||
scheduler.log(fn.func_name)
|
@ -4,7 +4,7 @@
|
||||
import webnotes
|
||||
from webnotes.utils import cint
|
||||
|
||||
def get_website_settings(context):
|
||||
def update_website_context(context):
|
||||
post_login = []
|
||||
cart_enabled = cint(webnotes.conn.get_default("shopping_cart_enabled"))
|
||||
if cart_enabled:
|
||||
|
@ -343,7 +343,7 @@ def create_material_request(material_requests):
|
||||
exceptions_list.append([] + webnotes.local.message_log)
|
||||
webnotes.local.message_log = []
|
||||
else:
|
||||
exceptions_list.append(webnotes.getTraceback())
|
||||
exceptions_list.append(webnotes.get_traceback())
|
||||
|
||||
if mr_list:
|
||||
if getattr(webnotes.local, "reorder_email_notify", None) is None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user