fix: Merge branch 'develop' into healthcare_refactor
diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py
index b465a10..4d0520a 100644
--- a/erpnext/controllers/status_updater.py
+++ b/erpnext/controllers/status_updater.py
@@ -69,6 +69,17 @@
 		["Cancelled", "eval:self.docstatus==2"],
 		["Closed", "eval:self.status=='Closed'"],
 	],
+	"Purchase Invoice": [	
+		["Draft", None],	
+		["Submitted", "eval:self.docstatus==1"],	
+		["Paid", "eval:self.outstanding_amount==0 and self.docstatus==1"],	
+		["Return", "eval:self.is_return==1 and self.docstatus==1"],	
+		["Debit Note Issued",	
+			"eval:self.outstanding_amount <= 0 and self.docstatus==1 and self.is_return==0 and get_value('Purchase Invoice', {'is_return': 1, 'return_against': self.name, 'docstatus': 1})"],	
+		["Unpaid", "eval:self.outstanding_amount > 0 and getdate(self.due_date) >= getdate(nowdate()) and self.docstatus==1"],	
+		["Overdue", "eval:self.outstanding_amount > 0 and getdate(self.due_date) < getdate(nowdate()) and self.docstatus==1"],	
+		["Cancelled", "eval:self.docstatus==2"],	
+	],
 	"Material Request": [
 		["Draft", None],
 		["Stopped", "eval:self.status == 'Stopped'"],
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index d452fe4..f6908c0 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -238,7 +238,7 @@
 		for d in self.items:
 			if not d.batch_no: continue
 
-			serial_nos = [d.name for d in frappe.get_all("Serial No", {'batch_no': d.batch_no})]
+			serial_nos = [sr.name for sr in frappe.get_all("Serial No", {'batch_no': d.batch_no})]
 			if serial_nos:
 				frappe.db.set_value("Serial No", { 'name': ['in', serial_nos] }, "batch_no", None)