Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 'Email Salary Slips' bulk action in salary slip list view (backport #1063) #1064

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions hrms/payroll/doctype/salary_slip/salary_slip.py
Original file line number Diff line number Diff line change
Expand Up @@ -2301,3 +2301,25 @@ def _check_attributes(code: str) -> None:
and node.attr in UNSAFE_ATTRIBUTES
):
raise SyntaxError(f'Illegal rule {frappe.bold(code)}. Cannot use "{node.attr}"')


@frappe.whitelist()
def enqueue_email_salary_slips(names) -> None:
"""enqueue bulk emailing salary slips"""
import json

if isinstance(names, str):
names = json.loads(names)

frappe.enqueue("hrms.payroll.doctype.salary_slip.salary_slip.email_salary_slips", names=names)
frappe.msgprint(
_("Salary slip emails have been enqueued for sending. Check {0} for status.").format(
f"""<a href='{frappe.utils.get_url_to_list("Email Queue")}' target='blank'>Email Queue</a>"""
)
)


def email_salary_slips(names) -> None:
for name in names:
salary_slip = frappe.get_doc("Salary Slip", name)
salary_slip.email_salary_slip()
19 changes: 16 additions & 3 deletions hrms/payroll/doctype/salary_slip/salary_slip_list.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
frappe.listview_settings['Salary Slip'] = {
add_fields: ["employee", "employee_name"],
};
frappe.listview_settings["Salary Slip"] = {
onload: function(listview) {
if (!has_common(frappe.user_roles, ["Administrator", "System Manager", "HR Manager", "HR User"])) return;

listview.page.add_menu_item(__("Email Salary Slips"), () => {
if (!listview.get_checked_items().length) {
frappe.msgprint(__("Please select the salary slips to email"));
return;
}

frappe.confirm(__("Are you sure you want to email the selected salary slips?"), () => {
listview.call_for_selected_items("hrms.payroll.doctype.salary_slip.salary_slip.enqueue_email_salary_slips");
});
});
}
}
Loading