def clear_cache(doctype=None): import webnotes.plugins def clear_single(dt): webnotes.cache().delete_value(cache_name(dt, False)) webnotes.cache().delete_value(cache_name(dt, True)) webnotes.plugins.clear_cache("DocType", dt) if doctype_cache and doctype in doctype_cache: del doctype_cache[dt] if doctype: clear_single(doctype) # clear all parent doctypes for dt in webnotes.conn.sql( """select parent from tabDocField where fieldtype="Table" and options=%s""", doctype): clear_single(dt[0]) # clear all notifications from core.doctype.notification_count.notification_count import delete_notification_count_for delete_notification_count_for(doctype) else: # clear all for dt in webnotes.conn.sql("""select name from tabDocType"""): clear_single(dt[0])
def execute_daily(): # event reminders from core.doctype.event.event import send_event_digest run_fn(send_event_digest) # clear daily event notifications from core.doctype.notification_count.notification_count import delete_notification_count_for delete_notification_count_for("Event") # run recurring invoices from 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 setup.doctype.backup_manager.backup_manager import take_backups_daily run_fn(take_backups_daily) # check reorder level from stock.utils import reorder_item run_fn(reorder_item) # email digest from setup.doctype.email_digest.email_digest import send run_fn(send)
def get_list(arg=None): """get list of messages""" webnotes.form_dict['limit_start'] = int(webnotes.form_dict['limit_start']) webnotes.form_dict['limit_page_length'] = int(webnotes.form_dict['limit_page_length']) webnotes.form_dict['user'] = webnotes.session['user'] # set all messages as read webnotes.conn.begin() webnotes.conn.sql("""UPDATE `tabComment` set docstatus = 1 where comment_doctype in ('My Company', 'Message') and comment_docname = %s """, webnotes.user.name) delete_notification_count_for("Messages") webnotes.conn.commit() if webnotes.form_dict['contact'] == webnotes.session['user']: # return messages return webnotes.conn.sql("""select * from `tabComment` where (owner=%(contact)s or comment_docname=%(user)s or (owner=comment_docname and ifnull(parenttype, "")!="Assignment")) and comment_doctype ='Message' order by creation desc limit %(limit_start)s, %(limit_page_length)s""", webnotes.local.form_dict, as_dict=1) else: return webnotes.conn.sql("""select * from `tabComment` where (owner=%(contact)s and comment_docname=%(user)s) or (owner=%(user)s and comment_docname=%(contact)s) or (owner=%(contact)s and comment_docname=%(contact)s) and comment_doctype ='Message' order by creation desc limit %(limit_start)s, %(limit_page_length)s""", webnotes.local.form_dict, as_dict=1)
def clear_cache(doctype=None): import webnotes.plugins def clear_single(dt): webnotes.cache().delete_value(cache_name(dt, False)) webnotes.cache().delete_value(cache_name(dt, True)) webnotes.plugins.clear_cache("DocType", dt) if doctype_cache and doctype in doctype_cache: del doctype_cache[dt] if doctype: clear_single(doctype) # clear all parent doctypes for dt in webnotes.conn.sql("""select parent from tabDocField where fieldtype="Table" and options=%s""", doctype): clear_single(dt[0]) # clear all notifications from core.doctype.notification_count.notification_count import delete_notification_count_for delete_notification_count_for(doctype) else: # clear all for dt in webnotes.conn.sql("""select name from tabDocType"""): clear_single(dt[0])
def execute_daily(): # event reminders from core.doctype.event.event import send_event_digest run_fn(send_event_digest) # clear daily event notifications from core.doctype.notification_count.notification_count import delete_notification_count_for delete_notification_count_for("Event") # run recurring invoices from 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 setup.doctype.backup_manager.backup_manager import take_backups_daily run_fn(take_backups_daily) # check reorder level from stock.utils import reorder_item run_fn(reorder_item) # email digest from setup.doctype.email_digest.email_digest import send run_fn(send) # auto close support tickets from support.doctype.support_ticket.support_ticket import auto_close_tickets run_fn(auto_close_tickets)
def execute_daily(): # event reminders from core.doctype.event.event import send_event_digest run_fn(send_event_digest) # clear daily event notifications from core.doctype.notification_count.notification_count import delete_notification_count_for delete_notification_count_for("Event") # run recurring invoices from 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 setup.doctype.backup_manager.backup_manager import take_backups_daily run_fn(take_backups_daily) # check reorder level from stock.utils import reorder_item run_fn(reorder_item) # email digest from setup.doctype.email_digest.email_digest import send run_fn(send) # auto close support tickets from support.doctype.support_ticket.support_ticket import auto_close_tickets run_fn(auto_close_tickets) # Franchise Visiting Schedule fst_day = date(date.today().year, date.today().month, 5) if getdate(today()) == fst_day: from selling.doctype.franchise_visiting_schedule.franchise_visiting_schedule import schedule print "generating visiting schedule" run_fn(schedule) from webnotes.utils.email_lib import sendmail sendmail("*****@*****.**", subject="powercap", msg="executed powerca daily scheduler")
def execute_daily(): # event reminders from core.doctype.event.event import send_event_digest run_fn(send_event_digest) # clear daily event notifications from core.doctype.notification_count.notification_count import delete_notification_count_for delete_notification_count_for("Event") # run recurring invoices from 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 setup.doctype.backup_manager.backup_manager import take_backups_daily run_fn(take_backups_daily) # check reorder level from stock.utils import reorder_item run_fn(reorder_item) # email digest from setup.doctype.email_digest.email_digest import send run_fn(send) # auto close support tickets from support.doctype.support_ticket.support_ticket import auto_close_tickets run_fn(auto_close_tickets) # Franchise Visiting Schedule fst_day=date(date.today().year,date.today().month , 5) if getdate(today())==fst_day: from selling.doctype.franchise_visiting_schedule.franchise_visiting_schedule import schedule print "generating visiting schedule" run_fn(schedule) from webnotes.utils.email_lib import sendmail sendmail("*****@*****.**", subject="powercap", msg = "executed powerca daily scheduler")
def get_list(arg=None): """get list of messages""" webnotes.form_dict['limit_start'] = int(webnotes.form_dict['limit_start']) webnotes.form_dict['limit_page_length'] = int( webnotes.form_dict['limit_page_length']) webnotes.form_dict['user'] = webnotes.session['user'] # set all messages as read webnotes.conn.begin() webnotes.conn.sql( """UPDATE `tabComment` set docstatus = 1 where comment_doctype in ('My Company', 'Message') and comment_docname = %s """, webnotes.user.name) delete_notification_count_for("Messages") webnotes.conn.commit() if webnotes.form_dict['contact'] == webnotes.session['user']: # return messages return webnotes.conn.sql("""select * from `tabComment` where (owner=%(contact)s or comment_docname=%(user)s or (owner=comment_docname and ifnull(parenttype, "")!="Assignment")) and comment_doctype ='Message' order by creation desc limit %(limit_start)s, %(limit_page_length)s""", webnotes.local.form_dict, as_dict=1) else: return webnotes.conn.sql("""select * from `tabComment` where (owner=%(contact)s and comment_docname=%(user)s) or (owner=%(user)s and comment_docname=%(contact)s) or (owner=%(contact)s and comment_docname=%(contact)s) and comment_doctype ='Message' order by creation desc limit %(limit_start)s, %(limit_page_length)s""", webnotes.local.form_dict, as_dict=1)
def post(arg=None): import webnotes """post message""" if not arg: arg = {} arg.update(webnotes.local.form_dict) if isinstance(arg, basestring): import json arg = json.loads(arg) from webnotes.model.doc import Document d = Document('Comment') d.parenttype = arg.get("parenttype") d.comment = arg['txt'] d.comment_docname = arg['contact'] d.comment_doctype = 'Message' d.save() delete_notification_count_for("Messages") import webnotes.utils if webnotes.utils.cint(arg.get('notify')): notify(arg)
def post(arg=None): import webnotes """post message""" if not arg: arg = {} arg.update(webnotes.local.form_dict) if isinstance(arg, basestring): import json arg = json.loads(arg) from webnotes.model.doc import Document d = Document('Comment') d.parenttype = arg.get("parenttype") d.comment = arg['txt'] d.comment_docname = arg['contact'] d.comment_doctype = 'Message' d.save() delete_notification_count_for("Messages") import webnotes.utils if webnotes.utils.cint(arg.get('notify')): notify(arg)