[fix] On deletion of salary slip decrease the series count (#14508)
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py
index 5fbd3b1..5f195d9 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.py
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.py
@@ -14,8 +14,12 @@
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 @@
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")