Can I get list say salary slip list based on status (draft, cancelled etc) while loading data. Don’t want to show cancelled or drafted records to employees
Hi, @Pretty_Gupta
Yes, this is possible
import frappe
# Connect to the Frappe database
frappe.init(site="your_site_name")
# Define the status to filter by
status = "Submitted"
# Retrieve the salary slips based on the status
salary_slips = frappe.get_all("Salary Slip", filters={"docstatus": 1, "status": status})
# Filter out the cancelled and drafted records
filtered_salary_slips = [slip for slip in salary_slips if slip.get("status") not in ["Draft", "Cancelled"]]
# Do something with the filtered salary slips
for slip in filtered_salary_slips:
# Do something with each salary slip, e.g. display it to the employee
print(slip)
# Disconnect from the database
frappe.destroy()
Hope this will help you out.
Thank you.
Thanks for the update. But in ERPNext it is controlled by listview settings injs files and we dont have anything in py files. Can you suggest me a way
https://frappeframework.com/docs/v14/user/en/api/list#standard-list-js
You can set default filters in list JS
But that can be changed by user. Don’t want that user can change the filter for that