Notifications about timesheet

I want to send an email alert if an employee forgets to fill the timesheet for a consecutive 2 days how is it possible. I tried using notification but I was not successful. Can anyone help pls?

Maybe give details? Please specify what you tried and learned, actual versus expected result etc, then folks can offer you pointers?

https://docs.erpnext.com/docs/user/manual/en/setting-up/notifications

@clarkej Actually I want that who dont fill the timesheet the mail should only go to them. And I was not able to understand as to what should be the reference date becase even if one of the employee creates or modifies a timesheet it would take the value and be updates . I want it to check for each of the employees whether they have filled or not and accordingly send the mail. WHat should be the reference date in notification or is there any other method

For context to grasp and debug what you attempted, maybe share your implementation details?

@clarkej I have attached the screenshot of my implementation I understand the following would send and email to every employee after 1 day of creation of any timesheet. If any employee creates a timesheet it would not send the notification

Good, now explore and use this q&a forum to advantage - you will unearth a world of ideas clues and pointer gems on your learning journey.

The assorted docs, videos and howto tutorials are your guides.

Your case probably will need to use these https://docs.erpnext.com/docs/user/manual/en/customize-erpnext/custom-scripts

@clarkej I am thinking to write a server script that fetches from timehseet table which employee did not fill it and then use send mails to these employees. But I dont know where to write it and I also want this script to run automatically daily at a particular time. how to do it in the backgroud. Can please tell how to start with it.

You best identify where you are stuck, and start your search there to learn how to do that?

@clarkej I have written a script in .py file as shown below also I have added cron in hooks.py of erpnext and enables scheduler when I run this file using bench --site execute the mails are properly sent however on bench --site trigger-scheduler-event I get an error as App not installed.How to solve it.I am attaching the screenshots of custom script hooks.py and error

So you have the tools you need!

Do copy and paste your screenshot code here, that is best and polite for your audience to check out, debug and learn by example.

Please keep us informed on your progress and what you discover.

Problem is solved the scheduler is working fine now…there was some syntax issues while writing cron.Thankyou

Nice! Please share and post for reference so all can learn and benefit:

  1. check.py 2) hooks.py and 3) your cron script code

“I get an error as App not installed.How to solve it.”

What was the problem here?

Thanks!

bench trigger-scheduler event cron still gives the error I believe this is not the exact syntax to trigger cron events.
The check.py file is

from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.utils import date_diff, nowdate
from datetime import date, datetime

def send_timesheet_reminder():
    print
    # yesterday=
    recepient_list=[]
    if date.today().weekday() == 0:
         employee_list=list(frappe.db.sql("""select distinct `tabTimesheet`.owner from `tabTimesheet`
        where (`tabTimesheet`.docstatus=1 or `tabTimesheet`.docstatus=0) and datediff(curdate(),`tabTimesheet`.end_date)<4"""))
    else:
        employee_list=list(frappe.db.sql("""select distinct `tabTimesheet`.owner from `tabTimesheet`
        where (`tabTimesheet`.docstatus=1 or `tabTimesheet`.docstatus=0) and datediff(curdate(),`tabTimesheet`.end_date)<2"""))

    full_employee_list=list(frappe.db.sql("""select `tabEmployee`.user_id from `tabEmployee` where `tabEmployee`.relieving_date is NULL"""))
    print(employee_list)
    # print(type(recepient_list))
    recepient_list=list(set(full_employee_list)-set(employee_list))
    print(type(recepient_list),recepient_list)
    content = """<h2>Timesheet not filled from two days</h2>
        <p>Please fill them as soon as possible</p><ol>"""
    for i in range(0,len(recepient_list)):
        frappe.sendmail(recipients=recepient_list[i],
            sender="tanzy@codekraft.in",
            subject="Timesheet not filled", content=content)

In hooks.py of erpnext I have added cron in scheduler events as

"cron": {
	 	"11 23 * * 1-5": [
	 		"erpnext.check.send_timesheet_reminder"
	 	]
	 }

as the first event and it is working fine already.

edit: highlight code