Hello there . I am facing this issue where color indicator do not work for draft or cancelled docs ? anyone can help ?
which doctype?
@bahaou You can set the get_indicator
function like this.
frappe.listview_settings['List Name'] = {
...
get_indicator(doc) {
let is_submittable = frappe.model.is_submittable(doc.doctype);
// customize indicator color
if (doc.docstatus === 0) {
return [__(is_submittable ? "Draft" : "Saved"), "green", "docstatus,=,0"];
} else if (is_submittable && doc.docstatus === 1) {
return [__("Submitted"), "green", "docstatus,=,1"];
} else if (is_submittable && doc.docstatus === 2) {
return [__("Cancelled"), "green", "docstatus,=,2"];
}
},
}
2 Likes
In order to set the indicator for documents in Draft status, you have to set the flag has_indicator_for_draft
. If you want to set it for Cancelled docs, you have to set the flag has_indicator_for_cancelled
. For the implementation, see frappe/indicator.js at 504b33ceb891d2c02518f8edd7d9b2cec50f47ba · frappe/frappe · GitHub
Your list view code, then, should look something like this:
frappe.listview_settings['List Name'] = {
...
has_indicator_for_draft: true,
has_indicator_for_cancelled: true,
get_indicator(doc) {
...
},
}
3 Likes