diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py index 24ecf26a66..dc2446ba35 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/salary_slip.py @@ -447,7 +447,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")) and not frappe.flags.via_payroll_entry: + 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): @@ -466,7 +466,10 @@ class SalarySlip(TransactionBase): "reference_doctype": self.doctype, "reference_name": self.name } - enqueue(method=frappe.sendmail, queue='short', timeout=300, async=True, **email_args) + if not frappe.flags.in_test: + enqueue(method=frappe.sendmail, queue='short', timeout=300, async=True, **email_args) + else: + frappe.sendmail(**email_args) else: msgprint(_("{0}: Employee email not found, hence email not sent").format(self.employee_name)) diff --git a/erpnext/hr/doctype/salary_slip/test_salary_slip.py b/erpnext/hr/doctype/salary_slip/test_salary_slip.py index b10df8bf9c..95be748b7e 100644 --- a/erpnext/hr/doctype/salary_slip/test_salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/test_salary_slip.py @@ -279,7 +279,7 @@ def make_salary_structure(sal_struct, payroll_frequency, employee): "payroll_frequency": payroll_frequency, "payment_account": get_random("Account") }).insert() - create_salary_structure_assignment(employee, salary_structure) + create_salary_structure_assignment(employee, salary_structure.name) elif not frappe.db.get_value("Salary Structure Assignment",{'salary_structure':sal_struct, 'employee':employee},'name'): create_salary_structure_assignment(employee, sal_struct)