Merge pull request #25803 from surajshetty3416/fix-extend-cscript

This commit is contained in:
Suraj Shetty 2021-05-23 13:39:09 +05:30 committed by GitHub
commit 540c82712a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 39 additions and 35 deletions

View File

@ -151,6 +151,7 @@
"context": true, "context": true,
"before": true, "before": true,
"beforeEach": true, "beforeEach": true,
"onScan": true "onScan": true,
"extend_cscript": true
} }
} }

View File

@ -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}));

View File

@ -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', { frappe.ui.form.on('POS Invoice', {
redeem_loyalty_points: function(frm) { redeem_loyalty_points: function(frm) {
@ -235,4 +235,4 @@ frappe.ui.form.on('POS Invoice', {
}); });
}); });
} }
}); });

View File

@ -451,7 +451,7 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e
}; };
// for backward compatibility: combine new and previous states // 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() { cur_frm.cscript['Make Delivery Note'] = function() {
frappe.model.open_mapped_doc({ frappe.model.open_mapped_doc({

View File

@ -547,7 +547,7 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends e
}; };
// for backward compatibility: combine new and previous states // 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){ cur_frm.cscript.update_status= function(label, status){
frappe.call({ frappe.call({

View File

@ -414,4 +414,4 @@ erpnext.buying.RequestforQuotationController = class RequestforQuotationControll
}; };
// for backward compatibility: combine new and previous states // 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}));

View File

@ -95,7 +95,7 @@ erpnext.buying.SupplierQuotationController = class SupplierQuotationController e
}; };
// for backward compatibility: combine new and previous states // 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 = cur_frm.fields_dict['items'].grid.get_field('project').get_query =
function(doc, cdt, cdn) { function(doc, cdt, cdn) {

View File

@ -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 }));

View File

@ -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) { cur_frm.cscript.item_code = function(doc, cdt, cdn) {
var d = locals[cdt][cdn]; var d = locals[cdt][cdn];
@ -213,4 +213,4 @@ cur_frm.cscript.item_code = function(doc, cdt, cdn) {
} }
}) })
} }
} }

View File

@ -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}));

View File

@ -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}));

View File

@ -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) { cur_frm.cscript.hour_rate = function(doc) {
erpnext.bom.calculate_op_cost(doc); erpnext.bom.calculate_op_cost(doc);
@ -662,4 +662,4 @@ frappe.ui.form.on("BOM", "with_operations", function(frm) {
frm.set_value("operations", []); frm.set_value("operations", []);
} }
toggle_operations(frm); toggle_operations(frm);
}); });

View File

@ -166,7 +166,9 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
"account_list": frappe.flags.round_off_applicable_accounts "account_list": frappe.flags.round_off_applicable_accounts
}, },
callback(r) { callback(r) {
frappe.flags.round_off_applicable_accounts.push(...r.message); if (r.message) {
frappe.flags.round_off_applicable_accounts.push(...r.message);
}
} }
}); });
} }

View File

@ -5,7 +5,7 @@ frappe.provide('erpnext.accounts.dimensions');
erpnext.TransactionController = class TransactionController extends erpnext.taxes_and_totals { erpnext.TransactionController = class TransactionController extends erpnext.taxes_and_totals {
setup() { setup() {
this._super(); super.setup();
frappe.flags.hide_serial_batch_dialog = true; frappe.flags.hide_serial_batch_dialog = true;
frappe.ui.form.on(this.frm.doctype + " Item", "rate", function(frm, cdt, cdn) { frappe.ui.form.on(this.frm.doctype + " Item", "rate", function(frm, cdt, cdn) {
var item = frappe.get_doc(cdt, cdn); var item = frappe.get_doc(cdt, cdn);

View File

@ -57,4 +57,4 @@ erpnext.selling.InstallationNote = class InstallationNote extends frappe.ui.form
} }
}; };
$.extend(cur_frm.cscript, new erpnext.selling.InstallationNote({frm: cur_frm})); extend_cscript(cur_frm.cscript, new erpnext.selling.InstallationNote({frm: cur_frm}));

View File

@ -104,7 +104,7 @@ frappe.ui.form.on("Sales Order Item", {
erpnext.selling.SalesOrderController = class SalesOrderController extends erpnext.selling.SellingController { erpnext.selling.SalesOrderController = class SalesOrderController extends erpnext.selling.SellingController {
onload(doc, dt, dn) { onload(doc, dt, dn) {
super.onload(); super.onload(doc, dt, dn);
} }
refresh(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}));

View File

@ -1,7 +1,7 @@
// 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
$.extend(cur_frm.cscript, { extend_cscript(cur_frm.cscript, {
message: function () { message: function () {
var total_characters = this.frm.doc.message.length; var total_characters = this.frm.doc.message.length;
var total_msg = 1; var total_msg = 1;

View File

@ -1,30 +1,30 @@
// 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
$.extend(cur_frm.cscript, { extend_cscript(cur_frm.cscript, {
onload: function() { onload: function() {
if(cur_frm.doc.__islocal) { if(cur_frm.doc.__islocal) {
cur_frm.set_value("to_currency", frappe.defaults.get_global_default("currency")); cur_frm.set_value("to_currency", frappe.defaults.get_global_default("currency"));
} }
}, },
refresh: function() { refresh: function() {
cur_frm.cscript.set_exchange_rate_label(); cur_frm.cscript.set_exchange_rate_label();
}, },
from_currency: function() { from_currency: function() {
cur_frm.cscript.set_exchange_rate_label(); cur_frm.cscript.set_exchange_rate_label();
}, },
to_currency: function() { to_currency: function() {
cur_frm.cscript.set_exchange_rate_label(); cur_frm.cscript.set_exchange_rate_label();
}, },
set_exchange_rate_label: function() { set_exchange_rate_label: function() {
if(cur_frm.doc.from_currency && cur_frm.doc.to_currency) { if(cur_frm.doc.from_currency && cur_frm.doc.to_currency) {
var default_label = __(frappe.meta.docfield_map[cur_frm.doctype]["exchange_rate"].label); 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)); repl(" (1 %(from_currency)s = [?] %(to_currency)s)", cur_frm.doc));
} }
} }
}); });

View File

@ -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', { frappe.ui.form.on('Delivery Note', {
setup: function(frm) { setup: function(frm) {

View File

@ -433,7 +433,7 @@ erpnext.buying.MaterialRequestController = class MaterialRequestController exten
if (doc.material_request_type == "Customer Provided") { if (doc.material_request_type == "Customer Provided") {
return{ return{
query: "erpnext.controllers.queries.item_query", query: "erpnext.controllers.queries.item_query",
filters:{ filters:{
'customer': me.frm.doc.customer, 'customer': me.frm.doc.customer,
'is_stock_item':1 'is_stock_item':1
} }
@ -472,7 +472,7 @@ erpnext.buying.MaterialRequestController = class MaterialRequestController exten
}; };
// for backward compatibility: combine new and previous states // 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) { function set_schedule_date(frm) {
if(frm.doc.schedule_date){ if(frm.doc.schedule_date){

View File

@ -251,7 +251,7 @@ erpnext.stock.PurchaseReceiptController = class PurchaseReceiptController extend
}; };
// for backward compatibility: combine new and previous states // 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) { cur_frm.cscript.update_status = function(status) {
frappe.ui.form.is_saving = true; frappe.ui.form.is_saving = true;

View File

@ -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}));

View File

@ -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) { cur_frm.fields_dict['serial_no'].get_query = function(doc, cdt, cdn) {
var cond = []; var cond = [];
@ -93,4 +93,4 @@ cur_frm.fields_dict['item_code'].get_query = function(doc, cdt, cdn) {
] ]
} }
} }
}; };