From 8e74df09a46ed036bb7bf468cd3c8d2b7635a2c7 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Thu, 14 Jun 2018 11:47:21 +0530 Subject: [PATCH] [fix] On deletion of salary slip decrease the series count (#14508) --- erpnext/hr/doctype/salary_slip/salary_slip.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py index 5fbd3b1ff2..5f195d925c 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/salary_slip.py @@ -14,8 +14,12 @@ from erpnext.utilities.transaction_base import TransactionBase from frappe.utils.background_jobs import enqueue class SalarySlip(TransactionBase): + def __init__(self, *args, **kwargs): + super(SalarySlip, self).__init__(*args, **kwargs) + self.series = 'Sal Slip/{0}/.#####'.format(self.employee) + def autoname(self): - self.name = make_autoname('Sal Slip/' +self.employee + '/.#####') + self.name = make_autoname(self.series) def validate(self): self.status = self.get_status() @@ -418,6 +422,10 @@ class SalarySlip(TransactionBase): self.set_status() self.update_status() + def on_trash(self): + from frappe.model.naming import revert_series_if_last + revert_series_if_last(self.series, self.name) + def email_salary_slip(self): receiver = frappe.db.get_value("Employee", self.employee, "prefered_email")