From 71e93d669160dd019b8c75719883fdf37e1bb99b Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Thu, 28 Apr 2016 19:03:58 +0530 Subject: [PATCH] Added test cased --- erpnext/hr/doctype/salary_slip/salary_slip.py | 3 +-- erpnext/hr/doctype/salary_slip/test_salary_slip.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py index bf686d78d52..39adedd1325 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/salary_slip.py @@ -211,10 +211,9 @@ class SalarySlip(TransactionBase): def email_salary_slip(self): receiver = frappe.db.get_value("Employee", self.employee, "company_email") or \ frappe.db.get_value("Employee", self.employee, "personal_email") - if receiver: subj = 'Salary Slip - ' + cstr(self.month) +'/'+cstr(self.fiscal_year) frappe.sendmail([receiver], subject=subj, message = _("Please see attachment"), - attachments=[frappe.attach_print(self.doctype, self.name, file_name=self.name)]) + attachments=[frappe.attach_print(self.doctype, self.name, file_name=self.name)], bulk=True) 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 2383affa0af..106b8a205be 100644 --- a/erpnext/hr/doctype/salary_slip/test_salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/test_salary_slip.py @@ -96,6 +96,19 @@ class TestSalarySlip(unittest.TestCase): frappe.set_user("test_employee@example.com") self.assertTrue(salary_slip_test_employee.has_permission("read")) + + def test_email_salary_slip(self): + frappe.db.sql("delete from `tabBulk Email`") + + hr_settings = frappe.get_doc("HR Settings", "HR Settings") + hr_settings.email_salary_slip_to_employee = 1 + hr_settings.save() + + self.make_employee("test_employee@example.com") + self.make_employee_salary_slip("test_employee@example.com") + bulk_mails = frappe.db.sql("""select name from `tabBulk Email`""") + self.assertTrue(bulk_mails) + def make_employee(self, user): if not frappe.db.get_value("User", user): @@ -118,6 +131,7 @@ class TestSalarySlip(unittest.TestCase): "date_of_joining": "2013-01-01", "department": "_Test Department 1", "gender": "Female", + "company_email": user, "status": "Active" }).insert()