fix: Added Inactive serial no status (#21848)
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 4fd668c..eacede6 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -684,7 +684,7 @@
execute:frappe.rename_doc("Desk Page", "Getting Started", "Home", force=True)
erpnext.patches.v12_0.unset_customer_supplier_based_on_type_of_item_price
erpnext.patches.v12_0.set_valid_till_date_in_supplier_quotation
-erpnext.patches.v12_0.set_serial_no_status
+erpnext.patches.v12_0.set_serial_no_status #2020-05-21
erpnext.patches.v12_0.update_price_list_currency_in_bom
execute:frappe.delete_doc_if_exists('Dashboard', 'Accounts')
erpnext.patches.v13_0.update_actual_start_and_end_date_in_wo
diff --git a/erpnext/patches/v12_0/set_serial_no_status.py b/erpnext/patches/v12_0/set_serial_no_status.py
index abba37d..3b5f5ef 100644
--- a/erpnext/patches/v12_0/set_serial_no_status.py
+++ b/erpnext/patches/v12_0/set_serial_no_status.py
@@ -5,7 +5,7 @@
def execute():
frappe.reload_doc('stock', 'doctype', 'serial_no')
- serial_no_list = frappe.db.sql("""select name, delivery_document_type, warranty_expiry_date from `tabSerial No`
+ serial_no_list = frappe.db.sql("""select name, delivery_document_type, warranty_expiry_date, warehouse from `tabSerial No`
where (status is NULL OR status='')""", as_dict = 1)
if len(serial_no_list) > 20000:
frappe.db.auto_commit_on_many_writes = True
@@ -15,6 +15,8 @@
status = "Delivered"
elif serial_no.get("warranty_expiry_date") and getdate(serial_no.get("warranty_expiry_date")) <= getdate(nowdate()):
status = "Expired"
+ elif not serial_no.get("warehouse"):
+ status = "Inactive"
else:
status = "Active"
diff --git a/erpnext/stock/doctype/serial_no/serial_no.json b/erpnext/stock/doctype/serial_no/serial_no.json
index 731a730..d9f8b62 100644
--- a/erpnext/stock/doctype/serial_no/serial_no.json
+++ b/erpnext/stock/doctype/serial_no/serial_no.json
@@ -420,14 +420,14 @@
"fieldtype": "Select",
"in_standard_filter": 1,
"label": "Status",
- "options": "\nActive\nDelivered\nExpired",
+ "options": "\nActive\nInactive\nDelivered\nExpired",
"read_only": 1
}
],
"icon": "fa fa-barcode",
"idx": 1,
"links": [],
- "modified": "2020-04-08 13:29:58.517772",
+ "modified": "2020-05-21 19:29:58.517772",
"modified_by": "Administrator",
"module": "Stock",
"name": "Serial No",
diff --git a/erpnext/stock/doctype/serial_no/serial_no.py b/erpnext/stock/doctype/serial_no/serial_no.py
index 914eea3..f3514c7 100644
--- a/erpnext/stock/doctype/serial_no/serial_no.py
+++ b/erpnext/stock/doctype/serial_no/serial_no.py
@@ -42,6 +42,8 @@
self.status = "Delivered"
elif self.warranty_expiry_date and getdate(self.warranty_expiry_date) <= getdate(nowdate()):
self.status = "Expired"
+ elif not self.warehouse:
+ self.status = "Inactive"
else:
self.status = "Active"
diff --git a/erpnext/stock/doctype/serial_no/serial_no_list.js b/erpnext/stock/doctype/serial_no/serial_no_list.js
index 651f790..7526d1d 100644
--- a/erpnext/stock/doctype/serial_no/serial_no_list.js
+++ b/erpnext/stock/doctype/serial_no/serial_no_list.js
@@ -5,6 +5,8 @@
return [__("Delivered"), "green", "delivery_document_type,is,set"];
} else if (doc.warranty_expiry_date && frappe.datetime.get_diff(doc.warranty_expiry_date, frappe.datetime.nowdate()) <= 0) {
return [__("Expired"), "red", "warranty_expiry_date,not in,|warranty_expiry_date,<=,Today|delivery_document_type,is,not set"];
+ } else if (!doc.warehouse) {
+ return [__("Inactive"), "grey", "warehouse,is,not set"];
} else {
return [__("Active"), "green", "delivery_document_type,is,not set"];
}