[feature] progress bars on production order

This commit is contained in:
Rushabh Mehta
2016-04-15 11:24:05 +05:30
parent bd07ea43e8
commit 18fc39b609

View File

@@ -1,7 +1,8 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt // License: GNU General Public License v3. See license.txt
frappe.ui.form.on("Production Order", "onload", function(frm) { frappe.ui.form.on("Production Order", {
onload: function(frm) {
if (!frm.doc.status) if (!frm.doc.status)
frm.doc.status = 'Draft'; frm.doc.status = 'Draft';
@@ -19,9 +20,8 @@ frappe.ui.form.on("Production Order", "onload", function(frm) {
erpnext.production_order.set_custom_buttons(frm); erpnext.production_order.set_custom_buttons(frm);
erpnext.production_order.setup_company_filter(frm); erpnext.production_order.setup_company_filter(frm);
erpnext.production_order.setup_bom_filter(frm); erpnext.production_order.setup_bom_filter(frm);
}); },
refresh: function(frm) {
frappe.ui.form.on("Production Order", "refresh", function(frm) {
erpnext.toggle_naming_series(); erpnext.toggle_naming_series();
frm.set_intro(""); frm.set_intro("");
erpnext.production_order.set_custom_buttons(frm); erpnext.production_order.set_custom_buttons(frm);
@@ -29,13 +29,48 @@ frappe.ui.form.on("Production Order", "refresh", function(frm) {
if (frm.doc.docstatus === 0 && !frm.doc.__islocal) { if (frm.doc.docstatus === 0 && !frm.doc.__islocal) {
frm.set_intro(__("Submit this Production Order for further processing.")); frm.set_intro(__("Submit this Production Order for further processing."));
} }
if (frm.doc.docstatus===1) {
frm.trigger('show_progress');
}
},
show_progress: function(frm) {
var bars = [];
var message = '';
var added_min = false;
// produced qty
var title = __('{0} items produced', [frm.doc.produced_qty]);
bars.push({
'title': title,
'width': (frm.doc.produced_qty / frm.doc.qty * 100) + '%',
'progress_class': 'progress-bar-success'
});
if(bars[0].width=='0%') {
bars[0].width = '0.5%';
added_min = 0.5;
}
message = title;
// pending qty
var pending_complete = frm.doc.material_transferred_for_manufacturing - frm.doc.produced_qty;
if(pending_complete) {
var title = __('{0} items in progress', [pending_complete]);
bars.push({
'title': title,
'width': ((pending_complete / frm.doc.qty * 100) - added_min) + '%',
'progress_class': 'progress-bar-warning'
})
message = message + '. ' + title;
}
frm.dashboard.add_progress(__('Status'), bars, message);
}
}); });
frappe.ui.form.on("Production Order", "additional_operating_cost", function(frm) {
erpnext.production_order.calculate_total_cost(frm);
});
frappe.ui.form.on("Production Order Operation", "workstation", function(frm, cdt, cdn) {
frappe.ui.form.on("Production Order Operation", {
workstation: function(frm, cdt, cdn) {
var d = locals[cdt][cdn]; var d = locals[cdt][cdn];
if (d.workstation) { if (d.workstation) {
frappe.call({ frappe.call({
@@ -51,11 +86,11 @@ frappe.ui.form.on("Production Order Operation", "workstation", function(frm, cdt
} }
}) })
} }
}); },
time_in_mins: function(frm, cdt, cdn) {
frappe.ui.form.on("Production Order Operation", "time_in_mins", function(frm, cdt, cdn) {
erpnext.production_order.calculate_cost(frm.doc); erpnext.production_order.calculate_cost(frm.doc);
erpnext.production_order.calculate_total_cost(frm) erpnext.production_order.calculate_total_cost(frm);
}
}); });
erpnext.production_order = { erpnext.production_order = {
@@ -84,13 +119,20 @@ erpnext.production_order = {
} }
if (flt(doc.material_transferred_for_manufacturing) < flt(doc.qty)) { if (flt(doc.material_transferred_for_manufacturing) < flt(doc.qty)) {
frm.add_custom_button(__('Transfer Materials for Manufacture'), var btn = frm.add_custom_button(__('Start'),
cur_frm.cscript['Transfer Raw Materials'], __("Stock Entry")); cur_frm.cscript['Transfer Raw Materials']);
btn.addClass('btn-primary');
} }
if (flt(doc.produced_qty) < flt(doc.material_transferred_for_manufacturing)) { if (flt(doc.produced_qty) < flt(doc.material_transferred_for_manufacturing)) {
frm.add_custom_button(__('Update Finished Goods'), var btn = frm.add_custom_button(__('Finish'),
cur_frm.cscript['Update Finished Goods'], __("Stock Entry")); cur_frm.cscript['Update Finished Goods']);
if(doc.material_transferred_for_manufacturing==doc.qty) {
// all materials transferred for manufacturing,
// make this primary
btn.addClass('btn-primary');
}
} }
} }
@@ -179,7 +221,7 @@ $.extend(cur_frm.cscript, {
flt(this.frm.doc.qty) - flt(this.frm.doc.material_transferred_for_manufacturing); flt(this.frm.doc.qty) - flt(this.frm.doc.material_transferred_for_manufacturing);
frappe.prompt({fieldtype:"Int", label: __("Qty for {0}", [purpose]), fieldname:"qty", frappe.prompt({fieldtype:"Int", label: __("Qty for {0}", [purpose]), fieldname:"qty",
description: __("Max: {0}", [max]) }, description: __("Max: {0}", [max]), 'default': max },
function(data) { function(data) {
if(data.qty > max) { if(data.qty > max) {
frappe.msgprint(__("Quantity must not be more than {0}", [max])); frappe.msgprint(__("Quantity must not be more than {0}", [max]));