I want an employee to create only one timesheet every month. Is it possible to configure this?
Thanks
I want an employee to create only one timesheet every month. Is it possible to configure this?
Thanks
You can set the validation on server side.
employee = doc.employee
first_day = frappe.utils.get_first_day(frappe.utils.today())
last_day = frappe.utils.get_last_day(frappe.utils.today())
frappe.errprint(first_day)
frappe.errprint(last_day)
existing_timesheet = frappe.db.exists(
"Timesheet",
{
"employee": employee,
"start_date": ["between", [first_day, last_day]],
"docstatus": ["!=", 2]
}
)
if existing_timesheet:
frappe.throw("You can create only one timesheet per month.")
Is this under server script list which requires enabling the config?
hi @NCP also you can help me out when session user it having timer is running in timesheet A he donot create an timer in timesheet B .
Means one user i having one timer is running Can you please help me … please
employee can’t start a timer in a new timesheet if they already have a running timer in another one, you can add a logic on server side according to the scenario. This check will look for any open timers for that employee in other timesheets. If it finds a running timer, it stops the employee from starting a new one and shows a message asking them to stop the current timer first. This way, only one timer can run for an employee at a time, ensuring no overlaps.
@NCP Can you have Server script . please can you provide ? please i try it so many times but it getting me error when we complete a running timer timesheet .
please can help me for that . please
i have used this please check that get me error .
error is when you complete an existing running timesheet timer it getting me error also when you create an timer inside the timesheet it getting the error …
please check code below
ncomplete_entries = frappe.get_all(
"Timesheet Detail",
filters={
"parenttype": "Timesheet",
"owner": frappe.session.user,
"completed": 0
},
fields=["project"]
)
# If there is exactly one incomplete entry, prevent the user from creating a new Timesheet
if incomplete_entries:
frappe.throw("You have an incomplete timesheet entry. Please complete it before starting a new timesheet.")
No, i just provided the reference. now you have to develop your own way according to the scenario.