From be2ee18de4e4f5f5c1561f5d516c38366bdddae2 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 29 Apr 2016 17:22:42 +0530 Subject: [PATCH] [fixed] frappe.require is now async :boom: --- erpnext/accounts/doctype/c_form/c_form.js | 4 +- .../doctype/journal_entry/journal_entry.js | 2 +- .../payment_reconciliation_invoice.json | 25 +- .../financial_analytics.js | 2 +- .../report/balance_sheet/balance_sheet.js | 6 +- .../accounts/report/cash_flow/cash_flow.js | 16 +- .../profit_and_loss_statement.js | 19 +- .../purchase_invoice_trends.js | 10 +- .../sales_invoice_trends.js | 10 +- .../report/trial_balance/trial_balance.js | 123 +++--- .../purchase_common/purchase_common.js | 15 +- .../request_for_quotation.js | 2 +- .../purchase_order_trends.js | 10 +- .../crm/doctype/opportunity/opportunity.js | 2 +- .../upload_attendance/upload_attendance.js | 2 +- .../production_planning_tool.js | 2 +- erpnext/projects/doctype/project/project.js | 15 +- erpnext/projects/doctype/project/project.py | 9 + .../projects/doctype/time_log/time_log.json | 10 +- erpnext/public/build.json | 7 +- .../public/js/controllers/taxes_and_totals.js | 51 ++- erpnext/public/js/controllers/transaction.js | 163 ++++--- erpnext/public/js/stock_analytics.js | 405 +++++++++--------- .../installation_note/installation_note.js | 2 +- .../quotation_trends/quotation_trends.js | 9 +- .../sales_order_trends/sales_order_trends.js | 10 +- erpnext/selling/sales_common.js | 5 +- erpnext/stock/doctype/item/item.js | 26 +- .../landed_cost_voucher.js | 7 +- .../material_request/material_request.js | 2 +- .../stock/doctype/stock_entry/stock_entry.js | 5 - .../stock_reconciliation.js | 2 - .../page/stock_analytics/stock_analytics.js | 25 +- .../stock/page/stock_balance/stock_balance.js | 51 +-- .../delivery_note_trends.js | 9 +- .../purchase_receipt_trends.js | 9 +- .../maintenance_visit/maintenance_visit.js | 2 +- .../doctype/warranty_claim/warranty_claim.js | 3 +- erpnext/templates/form_grid/item_grid.html | 10 +- .../templates/form_grid/stock_entry_grid.html | 28 +- 40 files changed, 565 insertions(+), 550 deletions(-) diff --git a/erpnext/accounts/doctype/c_form/c_form.js b/erpnext/accounts/doctype/c_form/c_form.js index eed81cb8f9..92cdb635da 100644 --- a/erpnext/accounts/doctype/c_form/c_form.js +++ b/erpnext/accounts/doctype/c_form/c_form.js @@ -3,12 +3,12 @@ //c-form js file // ----------------------------- -frappe.require("assets/erpnext/js/utils.js"); + cur_frm.fields_dict.invoices.grid.get_field("invoice_no").get_query = function(doc) { return { filters: { - "docstatus": 1, + "docstatus": 1, "customer": doc.customer, "company": doc.company, "c_form_applicable": 'Yes', diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index fc29bc7a3d..bc337a150e 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -3,7 +3,7 @@ frappe.provide("erpnext.accounts"); frappe.provide("erpnext.journal_entry"); -frappe.require("assets/erpnext/js/utils.js"); + frappe.ui.form.on("Journal Entry", { refresh: function(frm) { diff --git a/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json b/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json index 5659f1fe82..9255eda878 100644 --- a/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json +++ b/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json @@ -13,9 +13,10 @@ "bold": 0, "collapsible": 0, "fieldname": "invoice_type", - "fieldtype": "Data", + "fieldtype": "Select", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, "label": "Invoice Type", @@ -24,6 +25,7 @@ "options": "Sales Invoice\nPurchase Invoice\nJournal Entry", "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 1, "report_hide": 0, "reqd": 0, @@ -36,17 +38,19 @@ "bold": 0, "collapsible": 0, "fieldname": "invoice_number", - "fieldtype": "Data", + "fieldtype": "Dynamic Link", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, "label": "Invoice Number", "length": 0, "no_copy": 0, - "options": "", + "options": "invoice_type", "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 1, "report_hide": 0, "reqd": 0, @@ -62,6 +66,7 @@ "fieldtype": "Date", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, "label": "Invoice Date", @@ -69,6 +74,7 @@ "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 1, "report_hide": 0, "reqd": 0, @@ -84,6 +90,7 @@ "fieldtype": "Column Break", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, "label": "", @@ -91,6 +98,7 @@ "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -106,6 +114,7 @@ "fieldtype": "Currency", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, "label": "Amount", @@ -113,6 +122,7 @@ "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 1, "report_hide": 0, "reqd": 0, @@ -128,6 +138,7 @@ "fieldtype": "Currency", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, "label": "Outstanding Amount", @@ -135,6 +146,7 @@ "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 1, "report_hide": 0, "reqd": 0, @@ -145,21 +157,24 @@ ], "hide_heading": 0, "hide_toolbar": 0, + "idx": 0, "in_create": 0, "in_dialog": 0, "is_submittable": 0, "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2015-11-16 06:29:51.516537", + "modified": "2016-04-29 05:47:14.124370", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Reconciliation Invoice", "name_case": "", "owner": "Administrator", "permissions": [], + "quick_entry": 1, "read_only": 0, "read_only_onload": 0, "sort_field": "modified", - "sort_order": "DESC" + "sort_order": "DESC", + "track_seen": 0 } \ No newline at end of file diff --git a/erpnext/accounts/page/financial_analytics/financial_analytics.js b/erpnext/accounts/page/financial_analytics/financial_analytics.js index ef373aaf29..c892738b57 100644 --- a/erpnext/accounts/page/financial_analytics/financial_analytics.js +++ b/erpnext/accounts/page/financial_analytics/financial_analytics.js @@ -12,7 +12,7 @@ frappe.pages['financial-analytics'].on_page_load = function(wrapper) { }; -frappe.require("assets/erpnext/js/account_tree_grid.js"); +{% include "erpnext/public/js/account_tree_grid.js" %} erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({ filters: [ diff --git a/erpnext/accounts/report/balance_sheet/balance_sheet.js b/erpnext/accounts/report/balance_sheet/balance_sheet.js index 933b40eb71..a20d47c784 100644 --- a/erpnext/accounts/report/balance_sheet/balance_sheet.js +++ b/erpnext/accounts/report/balance_sheet/balance_sheet.js @@ -1,6 +1,8 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.require("assets/erpnext/js/financial_statements.js"); +frappe.require("assets/erpnext/js/financial_statements.js", function() { + frappe.query_reports["Balance Sheet"] = erpnext.financial_statements; +}); + -frappe.query_reports["Balance Sheet"] = erpnext.financial_statements; diff --git a/erpnext/accounts/report/cash_flow/cash_flow.js b/erpnext/accounts/report/cash_flow/cash_flow.js index 464bd17022..f5ddd150e3 100644 --- a/erpnext/accounts/report/cash_flow/cash_flow.js +++ b/erpnext/accounts/report/cash_flow/cash_flow.js @@ -1,12 +1,12 @@ // Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.require("assets/erpnext/js/financial_statements.js"); +frappe.require("assets/erpnext/js/financial_statements.js", function() { + frappe.query_reports["Cash Flow"] = erpnext.financial_statements; -frappe.query_reports["Cash Flow"] = erpnext.financial_statements; - -frappe.query_reports["Cash Flow"]["filters"].push({ - "fieldname": "accumulated_values", - "label": __("Accumulated Values"), - "fieldtype": "Check" -}) \ No newline at end of file + frappe.query_reports["Cash Flow"]["filters"].push({ + "fieldname": "accumulated_values", + "label": __("Accumulated Values"), + "fieldtype": "Check" + }); +}); \ No newline at end of file diff --git a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js index 98a972b18e..91ec9d93ca 100644 --- a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js +++ b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js @@ -1,15 +1,12 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.require("assets/erpnext/js/financial_statements.js"); - -frappe.query_reports["Profit and Loss Statement"] = $.extend({}, erpnext.financial_statements); - -frappe.query_reports["Profit and Loss Statement"]["filters"].push({ - "fieldname": "accumulated_values", - "label": __("Accumulated Values"), - "fieldtype": "Check" -}); - -console.log(frappe.query_reports["Profit and Loss Statement"]); +frappe.require("assets/erpnext/js/financial_statements.js", function() { + frappe.query_reports["Profit and Loss Statement"] = $.extend({}, erpnext.financial_statements); + frappe.query_reports["Profit and Loss Statement"]["filters"].push({ + "fieldname": "accumulated_values", + "label": __("Accumulated Values"), + "fieldtype": "Check" + }); +}); \ No newline at end of file diff --git a/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.js b/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.js index 4b34ae55a0..cc00b2af30 100644 --- a/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.js +++ b/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.js @@ -1,8 +1,8 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.require("assets/erpnext/js/purchase_trends_filters.js"); - -frappe.query_reports["Purchase Invoice Trends"] = { - filters: get_filters() - } \ No newline at end of file +frappe.require("assets/erpnext/js/purchase_trends_filters.js", function() { + frappe.query_reports["Purchase Invoice Trends"] = { + filters: get_filters() + } +}); \ No newline at end of file diff --git a/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.js b/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.js index 471e7baa72..0f92223d38 100644 --- a/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.js +++ b/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.js @@ -1,8 +1,8 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.require("assets/erpnext/js/sales_trends_filters.js"); - -frappe.query_reports["Sales Invoice Trends"] = { - filters: get_filters() - } \ No newline at end of file +frappe.require("assets/erpnext/js/sales_trends_filters.js", function() { + frappe.query_reports["Sales Invoice Trends"] = { + filters: get_filters() + } +}); \ No newline at end of file diff --git a/erpnext/accounts/report/trial_balance/trial_balance.js b/erpnext/accounts/report/trial_balance/trial_balance.js index 97c8f6cee3..a20b1cb6c9 100644 --- a/erpnext/accounts/report/trial_balance/trial_balance.js +++ b/erpnext/accounts/report/trial_balance/trial_balance.js @@ -1,65 +1,66 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.require("assets/erpnext/js/financial_statements.js"); - -frappe.query_reports["Trial Balance"] = { - "filters": [ - { - "fieldname": "company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "default": frappe.defaults.get_user_default("Company"), - "reqd": 1 - }, - { - "fieldname": "fiscal_year", - "label": __("Fiscal Year"), - "fieldtype": "Link", - "options": "Fiscal Year", - "default": frappe.defaults.get_user_default("fiscal_year"), - "reqd": 1, - "on_change": function(query_report) { - var fiscal_year = query_report.get_values().fiscal_year; - if (!fiscal_year) { - return; +frappe.require("assets/erpnext/js/financial_statements.js", function() { + frappe.query_reports["Trial Balance"] = { + "filters": [ + { + "fieldname": "company", + "label": __("Company"), + "fieldtype": "Link", + "options": "Company", + "default": frappe.defaults.get_user_default("Company"), + "reqd": 1 + }, + { + "fieldname": "fiscal_year", + "label": __("Fiscal Year"), + "fieldtype": "Link", + "options": "Fiscal Year", + "default": frappe.defaults.get_user_default("fiscal_year"), + "reqd": 1, + "on_change": function(query_report) { + var fiscal_year = query_report.get_values().fiscal_year; + if (!fiscal_year) { + return; + } + frappe.model.with_doc("Fiscal Year", fiscal_year, function(r) { + var fy = frappe.model.get_doc("Fiscal Year", fiscal_year); + query_report.filters_by_name.from_date.set_input(fy.year_start_date); + query_report.filters_by_name.to_date.set_input(fy.year_end_date); + query_report.trigger_refresh(); + }); } - frappe.model.with_doc("Fiscal Year", fiscal_year, function(r) { - var fy = frappe.model.get_doc("Fiscal Year", fiscal_year); - query_report.filters_by_name.from_date.set_input(fy.year_start_date); - query_report.filters_by_name.to_date.set_input(fy.year_end_date); - query_report.trigger_refresh(); - }); - } - }, - { - "fieldname": "from_date", - "label": __("From Date"), - "fieldtype": "Date", - "default": frappe.defaults.get_user_default("year_start_date"), - }, - { - "fieldname": "to_date", - "label": __("To Date"), - "fieldtype": "Date", - "default": frappe.defaults.get_user_default("year_end_date"), - }, - { - "fieldname": "with_period_closing_entry", - "label": __("Period Closing Entry"), - "fieldtype": "Check", - "default": 1 - }, - { - "fieldname": "show_zero_values", - "label": __("Show zero values"), - "fieldtype": "Check" - }, - ], - "formatter": erpnext.financial_statements.formatter, - "tree": true, - "name_field": "account", - "parent_field": "parent_account", - "initial_depth": 3 -} + }, + { + "fieldname": "from_date", + "label": __("From Date"), + "fieldtype": "Date", + "default": frappe.defaults.get_user_default("year_start_date"), + }, + { + "fieldname": "to_date", + "label": __("To Date"), + "fieldtype": "Date", + "default": frappe.defaults.get_user_default("year_end_date"), + }, + { + "fieldname": "with_period_closing_entry", + "label": __("Period Closing Entry"), + "fieldtype": "Check", + "default": 1 + }, + { + "fieldname": "show_zero_values", + "label": __("Show zero values"), + "fieldtype": "Check" + }, + ], + "formatter": erpnext.financial_statements.formatter, + "tree": true, + "name_field": "account", + "parent_field": "parent_account", + "initial_depth": 3 + } +}); + diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js index b38b90e981..8617a26361 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.js +++ b/erpnext/buying/doctype/purchase_common/purchase_common.js @@ -4,9 +4,8 @@ frappe.provide("erpnext.buying"); cur_frm.cscript.tax_table = "Purchase Taxes and Charges"; -{% include 'erpnext/accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.js' %} -frappe.require("assets/erpnext/js/controllers/transaction.js"); +{% include 'erpnext/accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.js' %} cur_frm.email_field = "contact_email"; @@ -129,12 +128,12 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ item.rejected_qty = flt(item.received_qty - item.qty, precision("rejected_qty", item)); } } - + this._super(doc, cdt, cdn); this.conversion_factor(doc, cdt, cdn); - + }, - + received_qty: function(doc, cdt, cdn) { var item = frappe.get_doc(cdt, cdn); frappe.model.round_floats_in(item, ["qty", "received_qty"]); @@ -142,7 +141,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ item.qty = (item.qty < item.received_qty) ? item.qty : item.received_qty; this.qty(doc, cdt, cdn); }, - + rejected_qty: function(doc, cdt, cdn) { var item = frappe.get_doc(cdt, cdn); frappe.model.round_floats_in(item, ["received_qty", "rejected_qty"]); @@ -152,7 +151,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ __(frappe.meta.get_label(item.doctype, "received_qty", item.name))])); item.qty = item.rejected_qty = 0.0; } else { - + item.qty = flt(item.received_qty - item.rejected_qty, precision("qty", item)); } @@ -236,7 +235,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ erpnext.utils.get_address_display(this.frm, "shipping_address", "shipping_address_display", is_your_company_address=true) }, - + tc_name: function() { this.get_terms(); } 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 b8002ddcb7..72185315f1 100644 --- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js +++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js @@ -4,7 +4,7 @@ {% include 'erpnext/buying/doctype/purchase_common/purchase_common.js' %}; -frappe.require("assets/erpnext/js/utils.js"); + frappe.ui.form.on("Request for Quotation",{ setup: function(frm){ diff --git a/erpnext/buying/report/purchase_order_trends/purchase_order_trends.js b/erpnext/buying/report/purchase_order_trends/purchase_order_trends.js index dcf1df1c82..f7fe90fe46 100644 --- a/erpnext/buying/report/purchase_order_trends/purchase_order_trends.js +++ b/erpnext/buying/report/purchase_order_trends/purchase_order_trends.js @@ -1,8 +1,8 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.require("assets/erpnext/js/purchase_trends_filters.js"); - -frappe.query_reports["Purchase Order Trends"] = { - filters: get_filters() - } \ No newline at end of file +frappe.require("assets/erpnext/js/purchase_trends_filters.js", function() { + frappe.query_reports["Purchase Order Trends"] = { + filters: get_filters() + } +}); \ No newline at end of file diff --git a/erpnext/crm/doctype/opportunity/opportunity.js b/erpnext/crm/doctype/opportunity/opportunity.js index 337b6319ff..c918dade7f 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.js +++ b/erpnext/crm/doctype/opportunity/opportunity.js @@ -2,7 +2,7 @@ // License: GNU General Public License v3. See license.txt frappe.provide("erpnext.crm"); -frappe.require("assets/erpnext/js/utils.js"); + cur_frm.email_field = "contact_email"; frappe.ui.form.on("Opportunity", { customer: function(frm) { diff --git a/erpnext/hr/doctype/upload_attendance/upload_attendance.js b/erpnext/hr/doctype/upload_attendance/upload_attendance.js index 47ffec096b..c49720c7e5 100644 --- a/erpnext/hr/doctype/upload_attendance/upload_attendance.js +++ b/erpnext/hr/doctype/upload_attendance/upload_attendance.js @@ -2,7 +2,7 @@ // License: GNU General Public License v3. See license.txt -frappe.require("assets/erpnext/js/utils.js"); + frappe.provide("erpnext.hr"); erpnext.hr.AttendanceControlPanel = frappe.ui.form.Controller.extend({ diff --git a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js index 5b97397a3c..710862b120 100644 --- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js +++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js @@ -1,7 +1,7 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.require("assets/erpnext/js/utils.js"); + cur_frm.cscript.onload = function(doc) { cur_frm.set_value("company", frappe.defaults.get_user_default("Company")) diff --git a/erpnext/projects/doctype/project/project.js b/erpnext/projects/doctype/project/project.js index 5c1fb0d9f8..914839798c 100644 --- a/erpnext/projects/doctype/project/project.js +++ b/erpnext/projects/doctype/project/project.js @@ -43,20 +43,9 @@ frappe.ui.form.on("Project", { }); } + frm.dashboard.show_heatmap = true; + frm.dashboard.heatmap_message = __('This is based on the Time Logs created against this project'); frm.dashboard.show_dashboard(); - // frm.dashboard.add_section(frappe.render_template('project_dashboard', {project: frm.doc})); - - // var bars = []; - // bars.push({ - // 'title': __('Percent Complete'), - // 'width': (frm.doc.percent_complete || 1) + '%', - // 'progress_class': 'progress-bar-success' - // }) - // - // var message = __("{0}% complete", [frm.doc.percent_complete]); - // - // frm.dashboard.add_progress(__('Status'), bars, message); - } } diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py index 2cca7e2dc9..c5808a209d 100644 --- a/erpnext/projects/doctype/project/project.py +++ b/erpnext/projects/doctype/project/project.py @@ -154,8 +154,17 @@ def get_dashboard_data(name): from frappe.desk.notifications import get_open_count return { 'count': get_open_count('Project', name), + 'timeline_data': get_timeline_data(name) } +def get_timeline_data(name): + '''Return timeline for attendance''' + return dict(frappe.db.sql('''select unix_timestamp(from_time), count(*) + from `tabTime Log` where project=%s + and from_time > date_sub(curdate(), interval 1 year) + and docstatus < 2 + group by date(from_time)''', name)) + def get_project_list(doctype, txt, filters, limit_start, limit_page_length=20): return frappe.db.sql('''select distinct project.* from tabProject project, `tabProject User` project_user diff --git a/erpnext/projects/doctype/time_log/time_log.json b/erpnext/projects/doctype/time_log/time_log.json index ef61d41f42..25d62c43ea 100644 --- a/erpnext/projects/doctype/time_log/time_log.json +++ b/erpnext/projects/doctype/time_log/time_log.json @@ -461,7 +461,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "depends_on": "eval:doc.for_manufacturing", + "depends_on": "for_manufacturing", "fieldname": "section_break_11", "fieldtype": "Section Break", "hidden": 0, @@ -645,7 +645,8 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "depends_on": "", + "collapsible_depends_on": "", + "depends_on": "costing_rate", "fieldname": "section_break_24", "fieldtype": "Section Break", "hidden": 0, @@ -653,6 +654,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, + "label": "Cost", "length": 0, "no_copy": 0, "permlevel": 0, @@ -748,6 +750,7 @@ "bold": 0, "collapsible": 0, "default": "0", + "depends_on": "billable", "description": "", "fieldname": "billing_rate", "fieldtype": "Currency", @@ -801,6 +804,7 @@ "bold": 0, "collapsible": 0, "default": "0", + "depends_on": "billable", "description": "Will be updated only if Time Log is 'Billable'", "fieldname": "billing_amount", "fieldtype": "Currency", @@ -935,7 +939,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2016-04-29 03:45:50.096299", + "modified": "2016-04-29 05:19:18.247260", "modified_by": "Administrator", "module": "Projects", "name": "Time Log", diff --git a/erpnext/public/build.json b/erpnext/public/build.json index ab0f673ea3..1831907f5e 100644 --- a/erpnext/public/build.json +++ b/erpnext/public/build.json @@ -11,15 +11,20 @@ "public/js/feature_setup.js", "public/js/utils.js", "public/js/queries.js", + "public/js/sms_manager.js", "public/js/utils/party.js", "public/js/templates/address_list.html", "public/js/templates/contact_list.html", + "public/js/controllers/stock_controller.js", + "public/js/controllers/taxes_and_totals.js", + "public/js/controllers/transaction.js", "public/js/pos/pos.html", "public/js/pos/pos_bill_item.html", "public/js/pos/pos_item.html", "public/js/pos/pos_tax_row.html", "public/js/pos/pos.js", - "public/js/templates/item_selector.html" + "public/js/templates/item_selector.html", + "public/js/utils/item_selector.js" ], "js/item-dashboard.min.js": [ "stock/dashboard/item_dashboard.html", diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index b4e712a5f5..1a234a3b38 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -1,9 +1,6 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.provide("erpnext"); -frappe.require("assets/erpnext/js/controllers/stock_controller.js"); - erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ calculate_taxes_and_totals: function(update_paid_amount) { this.discount_amount_applied = false; @@ -59,7 +56,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ "to_currency": company_currency })); } - + } }, @@ -256,7 +253,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ me.round_off_totals(tax); // adjust Discount Amount loss in last tax iteration - if ((i == me.frm.doc["taxes"].length - 1) && me.discount_amount_applied + if ((i == me.frm.doc["taxes"].length - 1) && me.discount_amount_applied && me.frm.doc.apply_discount_on == "Grand Total" && me.frm.doc.discount_amount) me.adjust_discount_amount_loss(tax); } @@ -321,10 +318,10 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount + discount_amount_loss, precision("tax_amount", tax)); tax.total = flt(tax.total + discount_amount_loss, precision("total", tax)); - + this.set_in_company_currency(tax, ["total", "tax_amount_after_discount_amount"]); }, - + manipulate_grand_total_for_inclusive_tax: function() { var me = this; // if fully inclusive taxes and diff @@ -342,8 +339,8 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ last_tax.tax_amount += diff; last_tax.tax_amount_after_discount += diff; last_tax.total += diff; - - this.set_in_company_currency(last_tax, + + this.set_in_company_currency(last_tax, ["total", "tax_amount", "tax_amount_after_discount_amount"]); } } @@ -392,14 +389,14 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ // rounded totals if(frappe.meta.get_docfield(this.frm.doc.doctype, "rounded_total", this.frm.doc.name)) { - this.frm.doc.rounded_total = round_based_on_smallest_currency_fraction(this.frm.doc.grand_total, + this.frm.doc.rounded_total = round_based_on_smallest_currency_fraction(this.frm.doc.grand_total, this.frm.doc.currency, precision("rounded_total")); } if(frappe.meta.get_docfield(this.frm.doc.doctype, "base_rounded_total", this.frm.doc.name)) { var company_currency = this.get_company_currency(); - - this.frm.doc.base_rounded_total = - round_based_on_smallest_currency_fraction(this.frm.doc.base_grand_total, + + this.frm.doc.base_rounded_total = + round_based_on_smallest_currency_fraction(this.frm.doc.base_grand_total, company_currency, precision("base_rounded_total")); } }, @@ -497,28 +494,28 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ this.calculate_outstanding_amount(update_paid_amount); }, - + calculate_outstanding_amount: function(update_paid_amount) { // NOTE: // paid_amount and write_off_amount is only for POS Invoice // total_advance is only for non POS Invoice if(this.frm.doc.is_return || this.frm.doc.docstatus > 0) return; - + frappe.model.round_floats_in(this.frm.doc, ["grand_total", "total_advance", "write_off_amount"]); - if(this.frm.doc.party_account_currency == this.frm.doc.currency) { - var total_amount_to_pay = flt((this.frm.doc.grand_total - this.frm.doc.total_advance + if(this.frm.doc.party_account_currency == this.frm.doc.currency) { + var total_amount_to_pay = flt((this.frm.doc.grand_total - this.frm.doc.total_advance - this.frm.doc.write_off_amount), precision("grand_total")); } else { var total_amount_to_pay = flt( - (flt(this.frm.doc.grand_total*this.frm.doc.conversion_rate, precision("grand_total")) - - this.frm.doc.total_advance - this.frm.doc.base_write_off_amount), + (flt(this.frm.doc.grand_total*this.frm.doc.conversion_rate, precision("grand_total")) + - this.frm.doc.total_advance - this.frm.doc.base_write_off_amount), precision("base_grand_total") ); } - + if(this.frm.doc.doctype == "Sales Invoice" || this.frm.doc.doctype == "Purchase Invoice") { frappe.model.round_floats_in(this.frm.doc, ["paid_amount"]); - + if(this.frm.doc.is_pos || this.frm.doc.is_paid) { if(!this.frm.doc.paid_amount || update_paid_amount===undefined || update_paid_amount) { this.frm.doc.paid_amount = flt(total_amount_to_pay); @@ -529,16 +526,16 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ this.set_in_company_currency(this.frm.doc, ["paid_amount"]); this.frm.refresh_field("paid_amount"); this.frm.refresh_field("base_paid_amount"); - - var paid_amount = (this.frm.doc.party_account_currency == this.frm.doc.currency) ? + + var paid_amount = (this.frm.doc.party_account_currency == this.frm.doc.currency) ? this.frm.doc.paid_amount : this.frm.doc.base_paid_amount; - - var outstanding_amount = flt(total_amount_to_pay - flt(paid_amount), + + var outstanding_amount = flt(total_amount_to_pay - flt(paid_amount), precision("outstanding_amount")); - + } else if(this.frm.doc.doctype == "Purchase Invoice") { var outstanding_amount = flt(total_amount_to_pay, precision("outstanding_amount")); - } + } this.frm.set_value("outstanding_amount", outstanding_amount); } }) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 8e512e84bd..99036aa856 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1,13 +1,85 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.provide("erpnext"); -frappe.require([ - "assets/erpnext/js/controllers/taxes_and_totals.js", - "assets/erpnext/js/utils.js", - "assets/erpnext/js/utils/item_selector.js"]); - erpnext.TransactionController = erpnext.taxes_and_totals.extend({ + setup: function() { + frappe.ui.form.on(this.frm.doctype + " Item", "rate", function(frm, cdt, cdn) { + var item = frappe.get_doc(cdt, cdn); + frappe.model.round_floats_in(item, ["rate", "price_list_rate"]); + + if(item.price_list_rate) { + item.discount_percentage = flt((1 - item.rate / item.price_list_rate) * 100.0, precision("discount_percentage", item)); + } else { + item.discount_percentage = 0.0; + } + + cur_frm.cscript.set_gross_profit(item); + cur_frm.cscript.calculate_taxes_and_totals(); + }) + + frappe.ui.form.on(this.frm.cscript.tax_table, "rate", function(frm, cdt, cdn) { + cur_frm.cscript.calculate_taxes_and_totals(); + }) + + frappe.ui.form.on(this.frm.cscript.tax_table, "tax_amount", function(frm, cdt, cdn) { + cur_frm.cscript.calculate_taxes_and_totals(); + }) + + frappe.ui.form.on(this.frm.cscript.tax_table, "row_id", function(frm, cdt, cdn) { + cur_frm.cscript.calculate_taxes_and_totals(); + }) + + frappe.ui.form.on(this.frm.cscript.tax_table, "included_in_print_rate", function(frm, cdt, cdn) { + cur_frm.cscript.set_dynamic_labels(); + cur_frm.cscript.calculate_taxes_and_totals(); + }) + + frappe.ui.form.on(this.frm.doctype, "apply_discount_on", function(frm) { + if(frm.doc.additional_discount_percentage) { + frm.trigger("additional_discount_percentage"); + } else { + cur_frm.cscript.calculate_taxes_and_totals(); + } + }) + + frappe.ui.form.on(this.frm.doctype, "additional_discount_percentage", function(frm) { + if (frm.via_discount_amount) { + return; + } + + if(!frm.doc.apply_discount_on) { + frappe.msgprint(__("Please set 'Apply Additional Discount On'")); + return + } + + frm.via_discount_percentage = true; + + if(frm.doc.additional_discount_percentage && frm.doc.discount_amount) { + // Reset discount amount and net / grand total + frm.set_value("discount_amount", 0); + } + + var total = flt(frm.doc[frappe.model.scrub(frm.doc.apply_discount_on)]); + var discount_amount = flt(total*flt(frm.doc.additional_discount_percentage) / 100, + precision("discount_amount")); + + frm.set_value("discount_amount", discount_amount); + delete frm.via_discount_percentage; + }); + + frappe.ui.form.on(this.frm.doctype, "discount_amount", function(frm) { + frm.cscript.set_dynamic_labels(); + + if (!frm.via_discount_percentage) { + frm.via_discount_amount = true; + frm.set_value("additional_discount_percentage", 0); + delete frm.via_discount_amount; + } + + frm.cscript.calculate_taxes_and_totals(); + }); + + }, onload: function() { var me = this; //this.frm.show_print_first = true; @@ -128,7 +200,6 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ }, send_sms: function() { - frappe.require("assets/erpnext/js/sms_manager.js"); var sms_man = new SMSManager(this.frm.doc); }, @@ -911,80 +982,4 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ -}); - -frappe.ui.form.on(cur_frm.doctype + " Item", "rate", function(frm, cdt, cdn) { - var item = frappe.get_doc(cdt, cdn); - frappe.model.round_floats_in(item, ["rate", "price_list_rate"]); - - if(item.price_list_rate) { - item.discount_percentage = flt((1 - item.rate / item.price_list_rate) * 100.0, precision("discount_percentage", item)); - } else { - item.discount_percentage = 0.0; - } - - cur_frm.cscript.set_gross_profit(item); - cur_frm.cscript.calculate_taxes_and_totals(); -}) - -frappe.ui.form.on(cur_frm.cscript.tax_table, "rate", function(frm, cdt, cdn) { - cur_frm.cscript.calculate_taxes_and_totals(); -}) - -frappe.ui.form.on(cur_frm.cscript.tax_table, "tax_amount", function(frm, cdt, cdn) { - cur_frm.cscript.calculate_taxes_and_totals(); -}) - -frappe.ui.form.on(cur_frm.cscript.tax_table, "row_id", function(frm, cdt, cdn) { - cur_frm.cscript.calculate_taxes_and_totals(); -}) - -frappe.ui.form.on(cur_frm.cscript.tax_table, "included_in_print_rate", function(frm, cdt, cdn) { - cur_frm.cscript.set_dynamic_labels(); - cur_frm.cscript.calculate_taxes_and_totals(); -}) - -frappe.ui.form.on(cur_frm.doctype, "apply_discount_on", function(frm) { - if(frm.doc.additional_discount_percentage) { - frm.trigger("additional_discount_percentage"); - } else { - cur_frm.cscript.calculate_taxes_and_totals(); - } -}) - -frappe.ui.form.on(cur_frm.doctype, "additional_discount_percentage", function(frm) { - if (frm.via_discount_amount) { - return; - } - - if(!frm.doc.apply_discount_on) { - frappe.msgprint(__("Please set 'Apply Additional Discount On'")); - return - } - - frm.via_discount_percentage = true; - - if(frm.doc.additional_discount_percentage && frm.doc.discount_amount) { - // Reset discount amount and net / grand total - frm.set_value("discount_amount", 0); - } - - var total = flt(frm.doc[frappe.model.scrub(frm.doc.apply_discount_on)]); - var discount_amount = flt(total*flt(frm.doc.additional_discount_percentage) / 100, - precision("discount_amount")); - - frm.set_value("discount_amount", discount_amount); - delete frm.via_discount_percentage; -}); - -frappe.ui.form.on(cur_frm.doctype, "discount_amount", function(frm) { - frm.cscript.set_dynamic_labels(); - - if (!frm.via_discount_percentage) { - frm.via_discount_amount = true; - frm.set_value("additional_discount_percentage", 0); - delete frm.via_discount_amount; - } - - frm.cscript.calculate_taxes_and_totals(); -}); +}); \ No newline at end of file diff --git a/erpnext/public/js/stock_analytics.js b/erpnext/public/js/stock_analytics.js index a8229baf0f..e9f97585f5 100644 --- a/erpnext/public/js/stock_analytics.js +++ b/erpnext/public/js/stock_analytics.js @@ -1,213 +1,214 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.require("assets/erpnext/js/stock_grid_report.js"); +frappe.require("assets/erpnext/js/stock_grid_report.js", function() { + erpnext.StockAnalytics = erpnext.StockGridReport.extend({ + init: function(wrapper, opts) { + var args = { + title: __("Stock Analytics"), + page: wrapper, + parent: $(wrapper).find('.layout-main'), + page: wrapper.page, + doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand", + "Fiscal Year", "Serial No"], + tree_grid: { + show: true, + parent_field: "parent_item_group", + formatter: function(item) { + if(!item.is_group) { + return repl("\ + %(value)s", { + value: item.name, + }); + } else { + return item.name; + } -erpnext.StockAnalytics = erpnext.StockGridReport.extend({ - init: function(wrapper, opts) { - var args = { - title: __("Stock Analytics"), - page: wrapper, - parent: $(wrapper).find('.layout-main'), - page: wrapper.page, - doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand", - "Fiscal Year", "Serial No"], - tree_grid: { - show: true, - parent_field: "parent_item_group", - formatter: function(item) { - if(!item.is_group) { - return repl("\ - %(value)s", { - value: item.name, - }); - } else { - return item.name; } - - } - }, - } - - if(opts) $.extend(args, opts); - - this._super(args); - }, - setup_columns: function() { - var std_columns = [ - {id: "_check", name: __("Plot"), field: "_check", width: 30, - formatter: this.check_formatter}, - {id: "name", name: __("Item"), field: "name", width: 300, - formatter: this.tree_formatter}, - {id: "brand", name: __("Brand"), field: "brand", width: 100}, - {id: "stock_uom", name: __("UOM"), field: "stock_uom", width: 100}, - {id: "opening", name: __("Opening"), field: "opening", hidden: true, - formatter: this.currency_formatter} - ]; - - this.make_date_range_columns(); - this.columns = std_columns.concat(this.columns); - }, - filters: [ - {fieldtype:"Select", label: __("Value or Qty"), fieldname: "value_or_qty", - options:[{label:__("Value"), value:"Value"}, {label:__("Quantity"), value:"Quantity"}], - filter: function(val, item, opts, me) { - return me.apply_zero_filter(val, item, opts, me); - }}, - {fieldtype:"Select", label: __("Brand"), link:"Brand", fieldname: "brand", - default_value: __("Select Brand..."), filter: function(val, item, opts) { - return val == opts.default_value || item.brand == val || item._show; - }, link_formatter: {filter_input: "brand"}}, - {fieldtype:"Select", label: __("Warehouse"), link:"Warehouse", fieldname: "warehouse", - default_value: __("Select Warehouse...")}, - {fieldtype:"Date", label: __("From Date"), fieldname: "from_date"}, - {fieldtype:"Date", label: __("To Date"), fieldname: "to_date"}, - {fieldtype:"Select", label: __("Range"), fieldname: "range", - options:[ - {label:__("Daily"), value:"Daily"}, - {label:__("Weekly"), value:"Weekly"}, - {label:__("Monthly"), value:"Monthly"}, - {label:__("Quarterly"), value:"Quarterly"}, - {label:__("Yearly"), value:"Yearly"}, - ]} - ], - setup_filters: function() { - var me = this; - this._super(); - - this.trigger_refresh_on_change(["value_or_qty", "brand", "warehouse", "range"]); - - this.show_zero_check(); - this.setup_plot_check(); - }, - init_filter_values: function() { - this._super(); - this.filter_inputs.range && this.filter_inputs.range.val('Monthly'); - }, - prepare_data: function() { - var me = this; - - if(!this.data) { - var items = this.prepare_tree("Item", "Item Group"); - - me.parent_map = {}; - me.item_by_name = {}; - me.data = []; - - $.each(items, function(i, v) { - var d = copy_dict(v); - - me.data.push(d); - me.item_by_name[d.name] = d; - if(d.parent_item_group) { - me.parent_map[d.name] = d.parent_item_group; - } - me.reset_item_values(d); - }); - this.set_indent(); - this.data[0].checked = true; - } else { - // otherwise, only reset values - $.each(this.data, function(i, d) { - me.reset_item_values(d); - d["closing_qty_value"] = 0; - }); - } - - this.prepare_balances(); - this.update_groups(); - - }, - prepare_balances: function() { - var me = this; - var from_date = dateutil.str_to_obj(this.from_date); - var to_date = dateutil.str_to_obj(this.to_date); - var data = frappe.report_dump.data["Stock Ledger Entry"]; - - this.item_warehouse = {}; - this.serialized_buying_rates = this.get_serialized_buying_rates(); - - for(var i=0, j=data.length; i' + __('Stock Ledger') + '']); - frm.dashboard.show_dashboard(); - - var section = frm.dashboard.add_section('
Stock Levels
'); - erpnext.item.item_dashboard = new erpnext.stock.ItemDashboard({ - parent: section, - item_code: frm.doc.name - }); - erpnext.item.item_dashboard.refresh(); }, @@ -184,6 +172,20 @@ $.extend(erpnext.item, { frm.dashboard.reset(); if(frm.doc.__islocal) return; + + frm.dashboard.show_heatmap = frm.doc.is_stock_item; + frm.dashboard.heatmap_message = __('This is based on stock movement. See {0} for details', + ['' + __('Stock Ledger') + '']); + frm.dashboard.show_dashboard(); + + frappe.require('assets/js/item-dashboard.min.js', function() { + var section = frm.dashboard.add_section('
Stock Levels
'); + erpnext.item.item_dashboard = new erpnext.stock.ItemDashboard({ + parent: section, + item_code: frm.doc.name + }); + erpnext.item.item_dashboard.refresh(); + }); }, edit_prices_button: function(frm) { diff --git a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js index 5a86c89d55..15a5759255 100644 --- a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js +++ b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js @@ -3,7 +3,6 @@ frappe.provide("erpnext.stock"); -frappe.require("assets/erpnext/js/controllers/stock_controller.js"); erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({ setup: function() { @@ -11,16 +10,16 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({ this.frm.fields_dict.purchase_receipts.grid.get_field('receipt_document').get_query = function(doc, cdt ,cdn) { var d = locals[cdt][cdn] - + var filters = [ [d.receipt_document_type, 'docstatus', '=', '1'], [d.receipt_document_type, 'company', '=', me.frm.doc.company], ] - + if(d.receipt_document_type == "Purchase Invoice") { filters.push(["Purchase Invoice", "update_stock", "=", "1"]) } - + if(!me.frm.doc.company) msgprint(__("Please enter company first")); return { filters:filters diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js index a4bae783f1..1dcbcb7916 100644 --- a/erpnext/stock/doctype/material_request/material_request.js +++ b/erpnext/stock/doctype/material_request/material_request.js @@ -3,7 +3,7 @@ {% include 'erpnext/buying/doctype/purchase_common/purchase_common.js' %}; -frappe.require("assets/erpnext/js/utils.js"); + frappe.ui.form.on("Material Request Item", { "qty": function(frm, doctype, name) { diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 1696b02ef2..76b039532a 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -1,10 +1,5 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.require([ - "assets/erpnext/js/controllers/stock_controller.js", - "assets/erpnext/js/utils.js", - "assets/erpnext/js/utils/item_selector.js"]); - frappe.provide("erpnext.stock"); erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js index f5f4e037d0..ead110ca74 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js @@ -1,8 +1,6 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.require("assets/erpnext/js/controllers/stock_controller.js"); -frappe.require("assets/erpnext/js/utils.js"); frappe.provide("erpnext.stock"); frappe.ui.form.on("Stock Reconciliation", { diff --git a/erpnext/stock/page/stock_analytics/stock_analytics.js b/erpnext/stock/page/stock_analytics/stock_analytics.js index bd2d9f6748..f86201f65d 100644 --- a/erpnext/stock/page/stock_analytics/stock_analytics.js +++ b/erpnext/stock/page/stock_analytics/stock_analytics.js @@ -1,19 +1,16 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt +frappe.require("assets/erpnext/js/stock_analytics.js", function() { + frappe.pages['stock-analytics'].on_page_load = function(wrapper) { + frappe.ui.make_app_page({ + parent: wrapper, + title: __('Stock Analytics'), + single_column: true + }); -frappe.pages['stock-analytics'].on_page_load = function(wrapper) { - frappe.ui.make_app_page({ - parent: wrapper, - title: __('Stock Analytics'), - single_column: true - }); + new erpnext.StockAnalytics(wrapper); - new erpnext.StockAnalytics(wrapper); - - - frappe.breadcrumbs.add("Stock") - -}; - -frappe.require("assets/erpnext/js/stock_analytics.js"); + frappe.breadcrumbs.add("Stock") + }; +}); diff --git a/erpnext/stock/page/stock_balance/stock_balance.js b/erpnext/stock/page/stock_balance/stock_balance.js index 7bf4792cb3..2b6fd8d492 100644 --- a/erpnext/stock/page/stock_balance/stock_balance.js +++ b/erpnext/stock/page/stock_balance/stock_balance.js @@ -1,5 +1,3 @@ -frappe.require('assets/js/item-dashboard.min.js'); - frappe.pages['stock-balance'].on_page_load = function(wrapper) { var page = frappe.ui.make_app_page({ parent: wrapper, @@ -52,32 +50,35 @@ frappe.pages['stock-balance'].on_page_load = function(wrapper) { page.sort_selector.wrapper.css({'margin-right': '15px', 'margin-top': '4px'}); - page.item_dashboard = new erpnext.stock.ItemDashboard({ - parent: page.main, - }) + frappe.require('assets/js/item-dashboard.min.js', function() { + page.item_dashboard = new erpnext.stock.ItemDashboard({ + parent: page.main, + }) - page.item_dashboard.before_refresh = function() { - this.item_code = page.item_field.get_value(); - this.warehouse = page.warehouse_field.get_value(); - } + page.item_dashboard.before_refresh = function() { + this.item_code = page.item_field.get_value(); + this.warehouse = page.warehouse_field.get_value(); + } - page.item_dashboard.refresh(); + page.item_dashboard.refresh(); - // item click - var setup_click = function(doctype) { - page.main.on('click', 'a[data-type="'+ doctype.toLowerCase() +'"]', function() { - var name = $(this).attr('data-name'); - var field = page[doctype.toLowerCase() + '_field']; - if(field.get_value()===name) { - frappe.set_route('Form', doctype, name) - } else { - field.set_input(name); - page.item_dashboard.refresh(); - } - }); - } + // item click + var setup_click = function(doctype) { + page.main.on('click', 'a[data-type="'+ doctype.toLowerCase() +'"]', function() { + var name = $(this).attr('data-name'); + var field = page[doctype.toLowerCase() + '_field']; + if(field.get_value()===name) { + frappe.set_route('Form', doctype, name) + } else { + field.set_input(name); + page.item_dashboard.refresh(); + } + }); + } + + setup_click('Item'); + setup_click('Warehouse'); + }); - setup_click('Item'); - setup_click('Warehouse'); } \ No newline at end of file diff --git a/erpnext/stock/report/delivery_note_trends/delivery_note_trends.js b/erpnext/stock/report/delivery_note_trends/delivery_note_trends.js index 45955fb345..0e129077b7 100644 --- a/erpnext/stock/report/delivery_note_trends/delivery_note_trends.js +++ b/erpnext/stock/report/delivery_note_trends/delivery_note_trends.js @@ -1,8 +1,9 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.require("assets/erpnext/js/sales_trends_filters.js"); +frappe.require("assets/erpnext/js/sales_trends_filters.js", function() { + frappe.query_reports["Delivery Note Trends"] = { + filters: get_filters() + } +}); -frappe.query_reports["Delivery Note Trends"] = { - filters: get_filters() - } \ No newline at end of file diff --git a/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.js b/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.js index 19a58efa70..d94b49e7dc 100644 --- a/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.js +++ b/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.js @@ -1,8 +1,9 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.require("assets/erpnext/js/purchase_trends_filters.js"); +frappe.require("assets/erpnext/js/purchase_trends_filters.js", function() { + frappe.query_reports["Purchase Receipt Trends"] = { + filters: get_filters() + } +}); -frappe.query_reports["Purchase Receipt Trends"] = { - filters: get_filters() - } \ No newline at end of file diff --git a/erpnext/support/doctype/maintenance_visit/maintenance_visit.js b/erpnext/support/doctype/maintenance_visit/maintenance_visit.js index b37c47b2eb..a267eb3ed0 100644 --- a/erpnext/support/doctype/maintenance_visit/maintenance_visit.js +++ b/erpnext/support/doctype/maintenance_visit/maintenance_visit.js @@ -2,7 +2,7 @@ // License: GNU General Public License v3. See license.txt frappe.provide("erpnext.support"); -frappe.require("assets/erpnext/js/utils.js"); + frappe.ui.form.on_change("Maintenance Visit", "customer", function(frm) { erpnext.utils.get_party_details(frm) }); diff --git a/erpnext/support/doctype/warranty_claim/warranty_claim.js b/erpnext/support/doctype/warranty_claim/warranty_claim.js index 39285779d7..0511ff6521 100644 --- a/erpnext/support/doctype/warranty_claim/warranty_claim.js +++ b/erpnext/support/doctype/warranty_claim/warranty_claim.js @@ -2,7 +2,8 @@ // License: GNU General Public License v3. See license.txt frappe.provide("erpnext.support"); -frappe.require("assets/erpnext/js/utils.js"); + +{% include "erpnext/public/js/utils.js" %} frappe.ui.form.on("Warranty Claim", { customer: function(frm) { diff --git a/erpnext/templates/form_grid/item_grid.html b/erpnext/templates/form_grid/item_grid.html index 1c50e15efd..c596890aa3 100644 --- a/erpnext/templates/form_grid/item_grid.html +++ b/erpnext/templates/form_grid/item_grid.html @@ -13,7 +13,7 @@
{% if(doc.warehouse) { - var label_class = "label-default", + var color = "grey", title = "Warehouse", actual_qty = (frm.doc.doctype==="Sales Order" ? doc.projected_qty : doc.actual_qty); @@ -21,16 +21,16 @@ && in_list(["Sales Order Item", "Delivery Note Item"], doc.doctype)) { if(actual_qty != undefined) { if(actual_qty >= doc.qty) { - var label_class = "label-success"; + var color = "green"; var title = "In Stock" } else { - var label_class = "label-danger"; + var color = "red"; var title = "Not In Stock" } } } %} - - + + {%= doc.warehouse %} diff --git a/erpnext/templates/form_grid/stock_entry_grid.html b/erpnext/templates/form_grid/stock_entry_grid.html index a2bf1df738..8604881812 100644 --- a/erpnext/templates/form_grid/stock_entry_grid.html +++ b/erpnext/templates/form_grid/stock_entry_grid.html @@ -16,21 +16,27 @@ {% if(doc.item_name != doc.item_code) { %}
{%= doc.item_name %}{% } %} {% include "templates/form_grid/includes/visible_cols.html" %} - {% if(frm.doc.docstatus==0 && doc.s_warehouse && doc.actual_qty < doc.qty) { %} - - Not in Stock - - {% } %}
- {% if(doc.s_warehouse) { %} - - {%= doc.s_warehouse || "" %} - {% } %} - {% if(doc.t_warehouse) { %} - {%= doc.t_warehouse || "" %}{% } %} + {% if(doc.s_warehouse) { + if(frm.doc.docstatus==0) { + var color = (doc.s_warehouse && doc.actual_qty < doc.qty) ? "red" : "green"; + var title = color === "red" ? __("Not in Stock") : __("In Stock"); + } else { + var color = "grey"; + var title = __("Source"); + } + %} + + {%= doc.s_warehouse %} + {% }; %} + {% if(doc.t_warehouse) { %} +
+ {%= doc.t_warehouse %} +
+ {% }; %}