fix: Status field in Serial No for filter and report builder

This commit is contained in:
marination 2020-04-08 15:38:28 +05:30
parent 0672b6b2e8
commit 86e8b2a1c6
5 changed files with 39 additions and 31 deletions

View File

@ -1,4 +1,5 @@
{
"actions": [],
"allow_import": 1,
"allow_rename": 1,
"autoname": "field:serial_no",
@ -41,7 +42,6 @@
"delivery_document_no",
"delivery_date",
"delivery_time",
"is_cancelled",
"column_break5",
"customer",
"customer_name",
@ -56,7 +56,8 @@
"warranty_period",
"more_info",
"serial_no_details",
"company"
"company",
"status"
],
"fields": [
{
@ -306,16 +307,6 @@
"no_copy": 1,
"read_only": 1
},
{
"fieldname": "is_cancelled",
"fieldtype": "Select",
"hidden": 1,
"label": "Is Cancelled",
"oldfieldname": "is_cancelled",
"oldfieldtype": "Select",
"options": "\nYes\nNo",
"report_hide": 1
},
{
"fieldname": "column_break5",
"fieldtype": "Column Break",
@ -423,11 +414,20 @@
"remember_last_selected_value": 1,
"reqd": 1,
"search_index": 1
},
{
"fieldname": "status",
"fieldtype": "Select",
"in_standard_filter": 1,
"label": "Status",
"options": "\nActive\nDelivered\nExpired",
"read_only": 1
}
],
"icon": "fa fa-barcode",
"idx": 1,
"modified": "2020-02-28 19:31:09.357323",
"links": [],
"modified": "2020-04-08 13:29:58.517772",
"modified_by": "Administrator",
"module": "Stock",
"name": "Serial No",

View File

@ -35,6 +35,15 @@ class SerialNo(StockController):
self.set_maintenance_status()
self.validate_warehouse()
self.validate_item()
self.set_status()
def set_status(self):
if self.delivery_document_type:
self.status = "Delivered"
elif self.warranty_expiry_date and getdate(self.warranty_expiry_date) <= getdate(nowdate()):
self.status = "Expired"
else:
self.status = "Active"
def set_maintenance_status(self):
if not self.warranty_expiry_date and not self.amc_expiry_date:
@ -197,6 +206,7 @@ class SerialNo(StockController):
self.set_purchase_details(last_sle.get("purchase_sle"))
self.set_sales_details(last_sle.get("delivery_sle"))
self.set_maintenance_status()
self.set_status()
def process_serial_no(sle):
item_det = get_item_details(sle.item_code)

View File

@ -1,14 +1,12 @@
frappe.listview_settings['Serial No'] = {
add_fields: ["is_cancelled", "item_code", "warehouse", "warranty_expiry_date", "delivery_document_type"],
add_fields: ["item_code", "warehouse", "warranty_expiry_date", "delivery_document_type"],
get_indicator: (doc) => {
if (doc.is_cancelled) {
return [__("Cancelled"), "red", "is_cancelled,=,Yes"];
} else if (doc.delivery_document_type) {
return [__("Delivered"), "green", "delivery_document_type,is,set|is_cancelled,=,No"];
if (doc.delivery_document_type) {
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|is_cancelled,=,No"];
return [__("Expired"), "red", "warranty_expiry_date,not in,|warranty_expiry_date,<=,Today|delivery_document_type,is,not set"];
} else {
return [__("Active"), "green", "delivery_document_type,is,not set|is_cancelled,=,No"];
return [__("Active"), "green", "delivery_document_type,is,not set"];
}
}
};