diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 99d080ae48..c534415d72 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -2,7 +2,7 @@ // License: GNU General Public License v3. See license.txt frappe.provide("erpnext.accounts"); -{% include 'buying/doctype/purchase_common/purchase_common.js' %}; +{% include 'erpnext/buying/doctype/purchase_common/purchase_common.js' %}; erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.js b/erpnext/accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.js index 56a2955300..433cda7372 100644 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.js +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.js @@ -3,7 +3,7 @@ cur_frm.cscript.tax_table = "Purchase Taxes and Charges"; -{% include "public/js/controllers/accounts.js" %} +{% include "erpnext/public/js/controllers/accounts.js" %} frappe.ui.form.on("Purchase Taxes and Charges", "add_deduct_tax", function(doc, cdt, cdn) { var d = locals[cdt][cdn]; diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 038d7e697c..c3c91a0764 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -4,7 +4,7 @@ // print heading cur_frm.pformat.print_heading = 'Invoice'; -{% include 'selling/sales_common.js' %}; +{% include 'erpnext/selling/sales_common.js' %}; frappe.provide("erpnext.accounts"); erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.extend({ diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.js b/erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.js index 8828e0c8e6..97a6fdd336 100644 --- a/erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.js +++ b/erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.js @@ -3,5 +3,5 @@ cur_frm.cscript.tax_table = "Sales Taxes and Charges"; -{% include "public/js/controllers/accounts.js" %} +{% include "erpnext/public/js/controllers/accounts.js" %} diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js index 79eaeeb3cc..b38b90e981 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.js +++ b/erpnext/buying/doctype/purchase_common/purchase_common.js @@ -4,7 +4,7 @@ frappe.provide("erpnext.buying"); cur_frm.cscript.tax_table = "Purchase Taxes and Charges"; -{% include 'accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.js' %} +{% include 'erpnext/accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.js' %} frappe.require("assets/erpnext/js/controllers/transaction.js"); diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js index b6026fd196..ddaa5b4e56 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.js +++ b/erpnext/buying/doctype/purchase_order/purchase_order.js @@ -3,7 +3,7 @@ frappe.provide("erpnext.buying"); -{% include 'buying/doctype/purchase_common/purchase_common.js' %}; +{% include 'erpnext/buying/doctype/purchase_common/purchase_common.js' %}; frappe.ui.form.on("Purchase Order", { onload: function(frm) { diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js index a072bd789f..b8002ddcb7 100644 --- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js +++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js @@ -2,7 +2,7 @@ // License: GNU General Public License v3. See license.txt -{% include 'buying/doctype/purchase_common/purchase_common.js' %}; +{% include 'erpnext/buying/doctype/purchase_common/purchase_common.js' %}; frappe.require("assets/erpnext/js/utils.js"); diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js index 96d69115e0..8587a9fdd7 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js @@ -2,7 +2,7 @@ // License: GNU General Public License v3. See license.txt // attach required files -{% include 'buying/doctype/purchase_common/purchase_common.js' %}; +{% include 'erpnext/buying/doctype/purchase_common/purchase_common.js' %}; erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.extend({ refresh: function() { diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index 9c287e75a7..f08cf4279d 100644 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -86,7 +86,7 @@ $.extend(erpnext.utils, { $(frm.fields_dict['address_html'].wrapper).html(""); frm.fields_dict['contact_html'] && $(frm.fields_dict['contact_html'].wrapper).html(""); }, - + render_address_and_contact: function(frm) { // render address $(frm.fields_dict['address_html'].wrapper) @@ -132,3 +132,22 @@ $(document).on('app_ready', function() { }); } }); + +erpnext.get_item_dashboard_data = function(data, max_count) { + if(!max_count) max_count = 0; + data.forEach(function(d) { + d.actual_or_pending = d.projected_qty + d.reserved_qty + d.reserved_qty_for_production; + d.pending_qty = 0; + d.total_reserved = d.reserved_qty + d.reserved_qty_for_production; + if(d.actual_or_pending > d.actual_qty) { + d.pending_qty = d.actual_or_pending - d.actual_qty; + } + + max_count = Math.max(d.actual_or_pending, d.actual_qty, + d.total_reserved, max_count); + }); + return { + data: data, + max_count: max_count + } +} diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 7c46983367..9e5283cfb8 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -2,7 +2,7 @@ // License: GNU General Public License v3. See license.txt -{% include 'selling/sales_common.js' %} +{% include 'erpnext/selling/sales_common.js' %} erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ onload: function(doc, dt, dn) { diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js index 22800b7acc..17050caac4 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.js +++ b/erpnext/selling/doctype/sales_order/sales_order.js @@ -1,7 +1,7 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -{% include 'selling/sales_common.js' %} +{% include 'erpnext/selling/sales_common.js' %} frappe.ui.form.on("Sales Order", { onload: function(frm) { diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index 607aa4124d..167024b1b4 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -3,7 +3,7 @@ cur_frm.cscript.tax_table = "Sales Taxes and Charges"; -{% include 'accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.js' %} +{% include 'erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.js' %} frappe.provide("erpnext.selling"); frappe.require("assets/erpnext/js/controllers/transaction.js"); diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js index 813133d184..6d3138667a 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note.js @@ -1,7 +1,7 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -{% include 'selling/sales_common.js' %}; +{% include 'erpnext/selling/sales_common.js' %}; frappe.provide("erpnext.stock"); frappe.provide("erpnext.stock.delivery_note"); diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js index 092bb31f98..2cde790da7 100644 --- a/erpnext/stock/doctype/item/item.js +++ b/erpnext/stock/doctype/item/item.js @@ -84,19 +84,10 @@ frappe.ui.form.on("Item", { dashboard_update: function(frm) { if(frm.dashboard_data.stock_data && frm.dashboard_data.stock_data.length) { - var max_count = 0; - frm.dashboard_data.stock_data.forEach(function(d) { - d.actual_or_pending = d.projected_qty - d.reserved_qty; - d.pending_qty = 0; - if(d.actual_or_pending > d.actual_qty) { - d.pending_qty = d.actual_or_pending - d.actual_qty; - } - - max_count = Math.max(d.actual_or_pending, d.actual_qty, - d.reserved_qty, max_count); - }) - frm.dashboard.add_stats(frappe.render_template('item_dashboard', - {data: frm.dashboard_data.stock_data, max_count: max_count})); + var context = erpnext.get_item_dashboard_data(frm.dashboard_data.stock_data, 0); + frm.dashboard.add_section('