Formatter, code cleanup (#12852)

This commit is contained in:
rohitwaghchaure 2018-02-12 11:25:58 +05:30 committed by Nabin Hait
parent 13afef2f72
commit 7477899d2e
6 changed files with 22 additions and 23 deletions

View File

@ -8,6 +8,10 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
setup: function(doc) {
this.setup_posting_date_time_check();
this._super(doc);
// formatter for material request item
this.frm.set_indicator_formatter('item_code',
function(doc) { return (doc.qty<=doc.received_qty) ? "green" : "orange" })
},
onload: function() {
this._super();
@ -20,10 +24,6 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
} else {
this.frm.set_value("disable_rounded_total", cint(frappe.sys_defaults.disable_rounded_total));
}
// formatter for material request item
this.frm.set_indicator_formatter('item_code',
function(doc) { return (doc.qty<=doc.received_qty) ? "green" : "orange" })
},
refresh: function(doc) {

View File

@ -12,6 +12,9 @@ frappe.ui.form.on("Purchase Order", {
'Purchase Invoice': 'Invoice',
'Stock Entry': 'Material to Supplier'
}
frm.set_indicator_formatter('item_code',
function(doc) { return (doc.qty<=doc.received_qty) ? "green" : "orange" })
},
onload: function(frm) {
@ -25,9 +28,6 @@ frappe.ui.form.on("Purchase Order", {
frm.toggle_display('get_last_purchase_rate',
frm.doc.__onload.disable_fetch_last_purchase_rate);
}
frm.set_indicator_formatter('item_code',
function(doc) { return (doc.qty<=doc.received_qty) ? "green" : "orange" })
},
});

View File

@ -4,14 +4,14 @@
/* global frappe, refresh_field */
frappe.ui.form.on("Supplier Scorecard", {
onload: function(frm) {
setup: function(frm) {
if (frm.doc.indicator_color !== "") {
frm.set_indicator_formatter("status", function(doc) {
return doc.indicator_color.toLowerCase();
});
}
},
onload: function(frm) {
if (frm.doc.__unsaved == 1) {
loadAllCriteria(frm);
loadAllStandings(frm);

View File

@ -79,6 +79,10 @@ frappe.ui.form.on("Production Order", {
]
}
});
// formatter for production order operation
frm.set_indicator_formatter('operation',
function(doc) { return (frm.doc.qty==doc.completed_qty) ? "green" : "orange" });
},
onload: function(frm) {
@ -94,10 +98,6 @@ frappe.ui.form.on("Production Order", {
});
erpnext.production_order.set_default_warehouse(frm);
}
// formatter for production order operation
frm.set_indicator_formatter('operation',
function(doc) { return (frm.doc.qty==doc.completed_qty) ? "green" : "orange" });
},
refresh: function(frm) {

View File

@ -13,6 +13,10 @@ frappe.ui.form.on("Sales Order", {
'Project': 'Project'
}
frm.add_fetch('customer', 'tax_id', 'tax_id');
// formatter for material request item
frm.set_indicator_formatter('item_code',
function(doc) { return (doc.stock_qty<=doc.delivered_qty) ? "green" : "orange" })
},
onload: function(frm) {
erpnext.queries.setup_queries(frm, "Warehouse", function() {
@ -28,10 +32,6 @@ frappe.ui.form.on("Sales Order", {
}
});
// formatter for material request item
frm.set_indicator_formatter('item_code',
function(doc) { return (doc.stock_qty<=doc.delivered_qty) ? "green" : "orange" })
erpnext.queries.setup_warehouse_query(frm);
},

View File

@ -12,6 +12,10 @@ frappe.ui.form.on('Material Request', {
'Supplier Quotation': 'Supplier Quotation',
'Production Order': 'Production Order'
}
// formatter for material request item
frm.set_indicator_formatter('item_code',
function(doc) { return (doc.qty<=doc.ordered_qty) ? "green" : "orange" })
},
onload: function(frm) {
// add item, if previous view was item
@ -19,11 +23,6 @@ frappe.ui.form.on('Material Request', {
//set schedule_date
set_schedule_date(frm);
// formatter for material request item
frm.set_indicator_formatter('item_code',
function(doc) { return (doc.qty<=doc.ordered_qty) ? "green" : "orange" }),
frm.fields_dict["items"].grid.get_field("warehouse").get_query = function(doc, cdt, cdn){
return{
filters: {'company': doc.company}