mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-02 08:03:21 +00:00
Rewrote hooks for scheduler, notifications, boot, session, login, webpage webnotes/wnframework#351
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user