diff --git a/.eslintrc b/.eslintrc index 3b6ab7498d..e40502acd6 100644 --- a/.eslintrc +++ b/.eslintrc @@ -151,6 +151,7 @@ "context": true, "before": true, "beforeEach": true, - "onScan": true + "onScan": true, + "extend_cscript": true } } diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js index 8dcd1aa8e7..c71a62dfb3 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js @@ -262,4 +262,4 @@ erpnext.accounts.PaymentReconciliationController = class PaymentReconciliationCo }; -$.extend(cur_frm.cscript, new erpnext.accounts.PaymentReconciliationController({frm: cur_frm})); +extend_cscript(cur_frm.cscript, new erpnext.accounts.PaymentReconciliationController({frm: cur_frm})); diff --git a/erpnext/accounts/doctype/pos_invoice/pos_invoice.js b/erpnext/accounts/doctype/pos_invoice/pos_invoice.js index 72d587afb5..181e9f8ec0 100644 --- a/erpnext/accounts/doctype/pos_invoice/pos_invoice.js +++ b/erpnext/accounts/doctype/pos_invoice/pos_invoice.js @@ -135,7 +135,7 @@ erpnext.selling.POSInvoiceController = class POSInvoiceController extends erpnex } } -$.extend(cur_frm.cscript, new erpnext.selling.POSInvoiceController({ frm: cur_frm })) +extend_cscript(cur_frm.cscript, new erpnext.selling.POSInvoiceController({ frm: cur_frm })) frappe.ui.form.on('POS Invoice', { redeem_loyalty_points: function(frm) { @@ -235,4 +235,4 @@ frappe.ui.form.on('POS Invoice', { }); }); } -}); \ No newline at end of file +}); diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 9e1dbf4333..16e70dd7ac 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -451,7 +451,7 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e }; // for backward compatibility: combine new and previous states -$.extend(cur_frm.cscript, new erpnext.accounts.SalesInvoiceController({frm: cur_frm})); +extend_cscript(cur_frm.cscript, new erpnext.accounts.SalesInvoiceController({frm: cur_frm})); cur_frm.cscript['Make Delivery Note'] = function() { frappe.model.open_mapped_doc({ diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js index c0e19e9c3d..384bbc5385 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.js +++ b/erpnext/buying/doctype/purchase_order/purchase_order.js @@ -547,7 +547,7 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends e }; // for backward compatibility: combine new and previous states -$.extend(cur_frm.cscript, new erpnext.buying.PurchaseOrderController({frm: cur_frm})); +extend_cscript(cur_frm.cscript, new erpnext.buying.PurchaseOrderController({frm: cur_frm})); cur_frm.cscript.update_status= function(label, status){ frappe.call({ 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 ee0e1ef576..bde00cbd94 100644 --- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js +++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js @@ -414,4 +414,4 @@ erpnext.buying.RequestforQuotationController = class RequestforQuotationControll }; // for backward compatibility: combine new and previous states -$.extend(cur_frm.cscript, new erpnext.buying.RequestforQuotationController({frm: cur_frm})); +extend_cscript(cur_frm.cscript, new erpnext.buying.RequestforQuotationController({frm: cur_frm})); diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js index a3ba52e67b..dc9c590dc5 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js @@ -95,7 +95,7 @@ erpnext.buying.SupplierQuotationController = class SupplierQuotationController e }; // for backward compatibility: combine new and previous states -$.extend(cur_frm.cscript, new erpnext.buying.SupplierQuotationController({frm: cur_frm})); +extend_cscript(cur_frm.cscript, new erpnext.buying.SupplierQuotationController({frm: cur_frm})); cur_frm.fields_dict['items'].grid.get_field('project').get_query = function(doc, cdt, cdn) { diff --git a/erpnext/crm/doctype/lead/lead.js b/erpnext/crm/doctype/lead/lead.js index 8dfee1d6c7..ebe85241d2 100644 --- a/erpnext/crm/doctype/lead/lead.js +++ b/erpnext/crm/doctype/lead/lead.js @@ -88,4 +88,4 @@ erpnext.LeadController = class LeadController extends frappe.ui.form.Controller } }; -$.extend(cur_frm.cscript, new erpnext.LeadController({ frm: cur_frm })); +extend_cscript(cur_frm.cscript, new erpnext.LeadController({ frm: cur_frm })); diff --git a/erpnext/crm/doctype/opportunity/opportunity.js b/erpnext/crm/doctype/opportunity/opportunity.js index 925c30b451..43e1b99f3a 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.js +++ b/erpnext/crm/doctype/opportunity/opportunity.js @@ -195,7 +195,7 @@ erpnext.crm.Opportunity = class Opportunity extends frappe.ui.form.Controller { } }; -$.extend(cur_frm.cscript, new erpnext.crm.Opportunity({frm: cur_frm})); +extend_cscript(cur_frm.cscript, new erpnext.crm.Opportunity({frm: cur_frm})); cur_frm.cscript.item_code = function(doc, cdt, cdn) { var d = locals[cdt][cdn]; @@ -213,4 +213,4 @@ cur_frm.cscript.item_code = function(doc, cdt, cdn) { } }) } -} \ No newline at end of file +} diff --git a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js index 2adfaf45ef..2371d9652c 100644 --- a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js +++ b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js @@ -115,5 +115,5 @@ erpnext.maintenance.MaintenanceSchedule = class MaintenanceSchedule extends frap } }; -$.extend(cur_frm.cscript, new erpnext.maintenance.MaintenanceSchedule({frm: cur_frm})); +extend_cscript(cur_frm.cscript, new erpnext.maintenance.MaintenanceSchedule({frm: cur_frm})); diff --git a/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js b/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js index 12dc59ccfc..503253040b 100644 --- a/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js +++ b/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js @@ -99,4 +99,4 @@ erpnext.maintenance.MaintenanceVisit = class MaintenanceVisit extends frappe.ui. } }; -$.extend(cur_frm.cscript, new erpnext.maintenance.MaintenanceVisit({frm: cur_frm})); +extend_cscript(cur_frm.cscript, new erpnext.maintenance.MaintenanceVisit({frm: cur_frm})); diff --git a/erpnext/manufacturing/doctype/bom/bom.js b/erpnext/manufacturing/doctype/bom/bom.js index b32b96af13..44f841f13b 100644 --- a/erpnext/manufacturing/doctype/bom/bom.js +++ b/erpnext/manufacturing/doctype/bom/bom.js @@ -405,7 +405,7 @@ erpnext.bom.BomController = class BomController extends erpnext.TransactionContr } }; -$.extend(cur_frm.cscript, new erpnext.bom.BomController({frm: cur_frm})); +extend_cscript(cur_frm.cscript, new erpnext.bom.BomController({frm: cur_frm})); cur_frm.cscript.hour_rate = function(doc) { erpnext.bom.calculate_op_cost(doc); @@ -662,4 +662,4 @@ frappe.ui.form.on("BOM", "with_operations", function(frm) { frm.set_value("operations", []); } toggle_operations(frm); -}); \ No newline at end of file +}); diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 31410da6bf..32439b6819 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -166,7 +166,9 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { "account_list": frappe.flags.round_off_applicable_accounts }, callback(r) { - frappe.flags.round_off_applicable_accounts.push(...r.message); + if (r.message) { + frappe.flags.round_off_applicable_accounts.push(...r.message); + } } }); } diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index b5337464ae..0ffda07cde 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -5,7 +5,7 @@ frappe.provide('erpnext.accounts.dimensions'); erpnext.TransactionController = class TransactionController extends erpnext.taxes_and_totals { setup() { - this._super(); + super.setup(); frappe.flags.hide_serial_batch_dialog = true; frappe.ui.form.on(this.frm.doctype + " Item", "rate", function(frm, cdt, cdn) { var item = frappe.get_doc(cdt, cdn); diff --git a/erpnext/selling/doctype/installation_note/installation_note.js b/erpnext/selling/doctype/installation_note/installation_note.js index ffa185baf6..27a3b35ccf 100644 --- a/erpnext/selling/doctype/installation_note/installation_note.js +++ b/erpnext/selling/doctype/installation_note/installation_note.js @@ -57,4 +57,4 @@ erpnext.selling.InstallationNote = class InstallationNote extends frappe.ui.form } }; -$.extend(cur_frm.cscript, new erpnext.selling.InstallationNote({frm: cur_frm})); \ No newline at end of file +extend_cscript(cur_frm.cscript, new erpnext.selling.InstallationNote({frm: cur_frm})); diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js index d5ceca8ec8..b42c615312 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.js +++ b/erpnext/selling/doctype/sales_order/sales_order.js @@ -104,7 +104,7 @@ frappe.ui.form.on("Sales Order Item", { erpnext.selling.SalesOrderController = class SalesOrderController extends erpnext.selling.SellingController { onload(doc, dt, dn) { - super.onload(); + super.onload(doc, dt, dn); } refresh(doc, dt, dn) { @@ -744,4 +744,5 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex }); } }; -$.extend(cur_frm.cscript, new erpnext.selling.SalesOrderController({frm: cur_frm})); + +extend_cscript(cur_frm.cscript, new erpnext.selling.SalesOrderController({frm: cur_frm})); diff --git a/erpnext/selling/doctype/sms_center/sms_center.js b/erpnext/selling/doctype/sms_center/sms_center.js index dda28031df..974cfc7918 100644 --- a/erpnext/selling/doctype/sms_center/sms_center.js +++ b/erpnext/selling/doctype/sms_center/sms_center.js @@ -1,7 +1,7 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -$.extend(cur_frm.cscript, { +extend_cscript(cur_frm.cscript, { message: function () { var total_characters = this.frm.doc.message.length; var total_msg = 1; diff --git a/erpnext/setup/doctype/currency_exchange/currency_exchange.js b/erpnext/setup/doctype/currency_exchange/currency_exchange.js index a8ea55ca0c..85036a163e 100644 --- a/erpnext/setup/doctype/currency_exchange/currency_exchange.js +++ b/erpnext/setup/doctype/currency_exchange/currency_exchange.js @@ -1,30 +1,30 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -$.extend(cur_frm.cscript, { +extend_cscript(cur_frm.cscript, { onload: function() { if(cur_frm.doc.__islocal) { cur_frm.set_value("to_currency", frappe.defaults.get_global_default("currency")); } }, - + refresh: function() { cur_frm.cscript.set_exchange_rate_label(); }, - + from_currency: function() { cur_frm.cscript.set_exchange_rate_label(); }, - + to_currency: function() { cur_frm.cscript.set_exchange_rate_label(); }, - + set_exchange_rate_label: function() { if(cur_frm.doc.from_currency && cur_frm.doc.to_currency) { var default_label = __(frappe.meta.docfield_map[cur_frm.doctype]["exchange_rate"].label); - cur_frm.fields_dict.exchange_rate.set_label(default_label + + cur_frm.fields_dict.exchange_rate.set_label(default_label + repl(" (1 %(from_currency)s = [?] %(to_currency)s)", cur_frm.doc)); } } -}); \ No newline at end of file +}); diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js index b736015808..c3803f19a1 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note.js @@ -305,7 +305,7 @@ erpnext.stock.DeliveryNoteController = class DeliveryNoteController extends erpn } }; -$.extend(cur_frm.cscript, new erpnext.stock.DeliveryNoteController({frm: cur_frm})); +extend_cscript(cur_frm.cscript, new erpnext.stock.DeliveryNoteController({frm: cur_frm})); frappe.ui.form.on('Delivery Note', { setup: function(frm) { diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js index f516e061c0..6585e1c78c 100644 --- a/erpnext/stock/doctype/material_request/material_request.js +++ b/erpnext/stock/doctype/material_request/material_request.js @@ -433,7 +433,7 @@ erpnext.buying.MaterialRequestController = class MaterialRequestController exten if (doc.material_request_type == "Customer Provided") { return{ query: "erpnext.controllers.queries.item_query", - filters:{ + filters:{ 'customer': me.frm.doc.customer, 'is_stock_item':1 } @@ -472,7 +472,7 @@ erpnext.buying.MaterialRequestController = class MaterialRequestController exten }; // for backward compatibility: combine new and previous states -$.extend(cur_frm.cscript, new erpnext.buying.MaterialRequestController({frm: cur_frm})); +extend_cscript(cur_frm.cscript, new erpnext.buying.MaterialRequestController({frm: cur_frm})); function set_schedule_date(frm) { if(frm.doc.schedule_date){ diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js index 688ae1d410..0182ed55a1 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js @@ -251,7 +251,7 @@ erpnext.stock.PurchaseReceiptController = class PurchaseReceiptController extend }; // for backward compatibility: combine new and previous states -$.extend(cur_frm.cscript, new erpnext.stock.PurchaseReceiptController({frm: cur_frm})); +extend_cscript(cur_frm.cscript, new erpnext.stock.PurchaseReceiptController({frm: cur_frm})); cur_frm.cscript.update_status = function(status) { frappe.ui.form.is_saving = true; diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 6afcd1f43e..700093fae3 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -1064,4 +1064,4 @@ erpnext.stock.select_batch_and_serial_no = (frm, item) => { } -$.extend(cur_frm.cscript, new erpnext.stock.StockEntry({frm: cur_frm})); +extend_cscript(cur_frm.cscript, new erpnext.stock.StockEntry({frm: cur_frm})); diff --git a/erpnext/support/doctype/warranty_claim/warranty_claim.js b/erpnext/support/doctype/warranty_claim/warranty_claim.js index c9aa41fdae..358768eb46 100644 --- a/erpnext/support/doctype/warranty_claim/warranty_claim.js +++ b/erpnext/support/doctype/warranty_claim/warranty_claim.js @@ -55,7 +55,7 @@ erpnext.support.WarrantyClaim = class WarrantyClaim extends frappe.ui.form.Contr } }; -$.extend(cur_frm.cscript, new erpnext.support.WarrantyClaim({frm: cur_frm})); +extend_cscript(cur_frm.cscript, new erpnext.support.WarrantyClaim({frm: cur_frm})); cur_frm.fields_dict['serial_no'].get_query = function(doc, cdt, cdn) { var cond = []; @@ -93,4 +93,4 @@ cur_frm.fields_dict['item_code'].get_query = function(doc, cdt, cdn) { ] } } -}; \ No newline at end of file +};