Merge pull request #19445 from scmmishra/typo-fix
fix: typo in production plan
diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py
index 97de40f..b73028e 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.py
+++ b/erpnext/hr/doctype/leave_application/leave_application.py
@@ -503,14 +503,17 @@
def get_pending_leaves_for_period(employee, leave_type, from_date, to_date):
''' Returns leaves that are pending approval '''
- return frappe.db.get_value("Leave Application",
+ leaves = frappe.get_all("Leave Application",
filters={
"employee": employee,
"leave_type": leave_type,
- "from_date": ("<=", from_date),
- "to_date": (">=", to_date),
"status": "Open"
- }, fieldname=['SUM(total_leave_days)']) or flt(0)
+ },
+ or_filters={
+ "from_date": ["between", (from_date, to_date)],
+ "to_date": ["between", (from_date, to_date)]
+ }, fields=['SUM(total_leave_days) as leaves'])[0]
+ return leaves['leaves'] if leaves['leaves'] else 0.0
def get_remaining_leaves(allocation, leaves_taken, date, expiry):
''' Returns minimum leaves remaining after comparing with remaining days for allocation expiry '''
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index 225ae29..c849f5b 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -39,9 +39,11 @@
names = [d[-1][1:] for d in filter(lambda x: len(x) > 1 and x[-1], names)]
# split by (-) if cancelled
- names = [cint(name.split('-')[-1]) for name in names]
-
- idx = max(names) + 1
+ if names:
+ names = [cint(name.split('-')[-1]) for name in names]
+ idx = max(names) + 1
+ else:
+ idx = 1
else:
idx = 1
@@ -290,7 +292,8 @@
return valuation_rate
def manage_default_bom(self):
- """ Uncheck others if current one is selected as default,
+ """ Uncheck others if current one is selected as default or
+ check the current one as default if it the only bom for the selected item,
update default bom in item master
"""
if self.is_default and self.is_active:
@@ -299,6 +302,9 @@
item = frappe.get_doc("Item", self.item)
if item.default_bom != self.name:
frappe.db.set_value('Item', self.item, 'default_bom', self.name)
+ elif not frappe.db.exists(dict(doctype='BOM', docstatus=1, item=self.item, is_default=1)) \
+ and self.is_active:
+ frappe.db.set(self, "is_default", 1)
else:
frappe.db.set(self, "is_default", 0)
item = frappe.get_doc("Item", self.item)