From 88c5de533a862429c5fc9e1b5fa2cb36cda79235 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Fri, 10 Mar 2023 15:32:30 +0530 Subject: [PATCH] fix: exclude carry forwarding leaves while updating leaves after submission --- erpnext/hr/doctype/leave_allocation/leave_allocation.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/erpnext/hr/doctype/leave_allocation/leave_allocation.py b/erpnext/hr/doctype/leave_allocation/leave_allocation.py index 8fae2a9a888..49ece5a2341 100755 --- a/erpnext/hr/doctype/leave_allocation/leave_allocation.py +++ b/erpnext/hr/doctype/leave_allocation/leave_allocation.py @@ -99,7 +99,11 @@ class LeaveAllocation(Document): # run required validations again since total leaves are being updated self.validate_leave_days_and_dates() - leaves_to_be_added = self.new_leaves_allocated - self.get_existing_leave_count() + leaves_to_be_added = ( + frappe.db.get_value("Leave Allocation", self.name, "new_leaves_allocated") + - self.get_existing_leave_count() + ) + args = { "leaves": leaves_to_be_added, "from_date": self.from_date, @@ -118,6 +122,7 @@ class LeaveAllocation(Document): "employee": self.employee, "company": self.company, "leave_type": self.leave_type, + "is_carry_forward": 0, }, pluck="leaves", )