I need to show the workflow state and status(paid,Unpaid after payment entry created) in the purchase invoice List, But the status in list field shows the Draft, Submitted or cancelled. The status field in purchase invoice is change to paid or partially paid , but the list view status does not show the actual status instead shows the document status.
You can override the status text and color by this
frappe.listview_settings["Doctype"] = {
get_indicator: function (doc) {
var colors = {
Paid: "green",
Unpaid: "red",
};
let status = doc.status ? "Paid" : "Unpaid"; // Here you can change the condition to your requirement
return [__(status), colors[status], "status,=," + status];
},
};
And here is the default code of Purchase Invoice List
get_indicator(doc) {
if (doc.status == "Debit Note Issued") {
return [__(doc.status), "gray", "status,=," + doc.status];
}
if (flt(doc.outstanding_amount) > 0 && doc.docstatus == 1 && cint(doc.on_hold)) {
if (!doc.release_date) {
return [__("On Hold"), "darkgrey"];
} else if (frappe.datetime.get_diff(doc.release_date, frappe.datetime.nowdate()) > 0) {
return [__("Temporarily on Hold"), "darkgrey"];
}
}
const status_colors = {
Unpaid: "orange",
Paid: "green",
Return: "gray",
Overdue: "red",
"Partly Paid": "yellow",
"Internal Transfer": "darkgrey",
};
if (status_colors[doc.status]) {
return [__(doc.status), status_colors[doc.status], "status,=," + doc.status];
}
},
Thanks for your reply. I have this code in purchase_invoice_list.js, but still I get the same result. I could not see the paid/unpaid status for a doctype which has a workflow setup.
After changing in js file I did
bench build
bench restart
but the changes is not reflected in web.
frappe.listview_settings[“Purchase Invoice”] = {
add_fields: [
“supplier”,
“supplier_name”,
“base_grand_total”,
“outstanding_amount”,
“due_date”,
“company”,
“currency”,
“is_return”,
“release_date”,
“on_hold”,
“represents_company”,
“is_internal_supplier”,
],
get_indicator: function (doc) {
if (doc.status == “Debit Note Issued”) {
return [__(doc.status), “gray”, “status,=,” + doc.status];
}
if (flt(doc.outstanding_amount) > 0 && doc.docstatus == 1 && cint(doc.on_hold)) {
if (!doc.release_date) {
return [__("On Hold"), "darkgrey"];
} else if (frappe.datetime.get_diff(doc.release_date, frappe.datetime.nowdate()) > 0) {
return [__("Temporarily on Hold"), "darkgrey"];
}
}
const status_colors = {
Unpaid: "orange",
Paid: "green",
Return: "gray",
Overdue: "red",
"Partly Paid": "yellow",
"Internal Transfer": "darkgrey",
};
let status = doc.status;
return [__(status), status_colors[status], "status,=," + status];
// let status = (flt(doc.outstanding_amount) <= 0 && doc.docstatus == 1) ? "Paid" : "Unpaid";
// if (status_colors[status]) {
// return [__(status), status_colors[status], "status,=," + status];
// return [__("Paid"), status_colors["Paid"], "status,=,Paid"];
// }
},
onload: function (listview) {
listview.page.add_action_item(__("Purchase Receipt"), () => {
erpnext.bulk_transaction_processing.create(listview, "Purchase Invoice", "Purchase Receipt");
});
listview.page.add_action_item(__("Payment"), () => {
erpnext.bulk_transaction_processing.create(listview, "Purchase Invoice", "Payment Entry");
});
},
};
Could you please help me @Ahmed_Muhamed
Thanks in advance
Are you sure in your custom JS file is loading on the web?
No its not Loading, I tried bench build and bench restart still its not working. Could you please help me to fix this issue
Try to configure by this way in hooks.py
doctype_list_js = {"doctype" : "public/js/doctype_list.js"}