Hi Frappe Community, @jls@Zaryabqureshi@NCP
I’m working on customizing the list view for the “Store Entry” doctype in my Frappe application. I have a field named entry_type which is a select field with two possible values: “STOCK-IN” and “STOCK-OUT”.
I would like to apply indicator colors to this field in the list view based on its values. Specifically, I want the following:
“STOCK-IN” should be displayed with a green indicator.
“STOCK-OUT” should be displayed with a red indicator.
Here’s a simplified version of my current list view settings:
javascript
Copy code
frappe.listview_settings["Store Entry"] = {
add_fields: [
"entry_type", // Ensure entry_type is included in the fields
// other fields...
],
get_indicator: function (doc) {
if (doc.entry_type === "STOCK-IN") {
return [__("STOCK-IN"), "green", "entry_type,=,STOCK-IN"];
} else if (doc.entry_type === "STOCK-OUT") {
return [__("STOCK-OUT"), "red", "entry_type,=,STOCK-OUT"];
}
return [__(doc.entry_type || "Unknown"), "gray", "entry_type,=," + (doc.entry_type || "Unknown")];
}
};
frappe.listview_settings["Store Entry"] = {
add_fields: [
"entry_type", // Ensure entry_type is included in the fields
// other fields...
],
get_indicator: function (doc) {
console.log("Processing document:", doc);
if (doc.entry_type === "STOCK-IN") {
console.log("Entry Type is STOCK-IN");
return [__("STOCK-IN"), "green", "entry_type,=,STOCK-IN"];
} else if (doc.entry_type === "STOCK-OUT") {
console.log("Entry Type is STOCK-OUT");
return [__("STOCK-OUT"), "red", "entry_type,=,STOCK-OUT"];
}
console.log("Entry Type is Unknown or not handled");
return [
__(doc.entry_type || "Unknown"),
"gray",
"entry_type,=," + (doc.entry_type || "Unknown"),
];
},
};
Indicators are not set in two fields at the same time. If the indicator is set for status, none of the other fields will be set. For that you have to apply custom logic, here I have given you reference, you have to overwrite the stock entry list code first.
I have done the logic for stock entry purpose, so you set the logic according to you!