From ea1408f2e04c03f62167b96027417f1f51f69055 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Mon, 16 Apr 2018 11:08:49 +0530 Subject: [PATCH] [fix] enqueue salary slip print email after completing accounting entries (#13633) --- erpnext/hr/doctype/payroll_entry/payroll_entry.py | 10 +++++++++- erpnext/hr/doctype/salary_slip/salary_slip.py | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/erpnext/hr/doctype/payroll_entry/payroll_entry.py b/erpnext/hr/doctype/payroll_entry/payroll_entry.py index 111df4c973..c9d6290f26 100644 --- a/erpnext/hr/doctype/payroll_entry/payroll_entry.py +++ b/erpnext/hr/doctype/payroll_entry/payroll_entry.py @@ -146,6 +146,7 @@ class PayrollEntry(Document): ss_list = self.get_sal_slip_list(ss_status=0) submitted_ss = [] not_submitted_ss = [] + frappe.flags.via_payroll_entry = True for ss in ss_list: ss_obj = frappe.get_doc("Salary Slip",ss[0]) ss_dict = {} @@ -159,7 +160,7 @@ class PayrollEntry(Document): else: try: ss_obj.submit() - submitted_ss.append(ss_dict) + submitted_ss.append(ss_obj) except frappe.ValidationError: not_submitted_ss.append(ss_dict) @@ -168,8 +169,15 @@ class PayrollEntry(Document): frappe.msgprint(_("Salary Slip submitted for period from {0} to {1}") .format(ss_obj.start_date, ss_obj.end_date)) + self.email_salary_slip(submitted_ss) + return create_submit_log(submitted_ss, not_submitted_ss, jv_name) + def email_salary_slip(self, submitted_ss): + if frappe.db.get_single_value("HR Settings", "email_salary_slip_to_employee"): + for ss in submitted_ss: + ss.email_salary_slip() + def get_loan_details(self): """ Get loan details from submitted salary slip based on selected criteria diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py index b9371e31fb..5fbd3b1ff2 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/salary_slip.py @@ -411,7 +411,7 @@ class SalarySlip(TransactionBase): else: self.set_status() self.update_status(self.name) - if(frappe.db.get_single_value("HR Settings", "email_salary_slip_to_employee")): + if(frappe.db.get_single_value("HR Settings", "email_salary_slip_to_employee")) and not frappe.flags.via_payroll_entry: self.email_salary_slip() def on_cancel(self):