From 6b5e1cfeb70f32c99b2f1dd8c4c98178c8e3cb31 Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Tue, 27 Feb 2024 11:18:58 +0530 Subject: [PATCH 1/2] fix: type error for missing frm obj (cherry picked from commit 20fa3da950f3834cac812c9702284c470fb19af2) --- erpnext/public/js/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index 456a215f10b7..640b5225ff4a 100755 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -27,7 +27,7 @@ $.extend(erpnext, { }, hide_company: function() { - if(cur_frm.fields_dict.company) { + if(cur_frm?.fields_dict.company) { var companies = Object.keys(locals[":Company"] || {}); if(companies.length === 1) { if(!cur_frm.doc.company) cur_frm.set_value("company", companies[0]); From 341f9030f5aa4fecfbedc519a2ef1e39f967f6fa Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Tue, 27 Feb 2024 13:05:29 +0530 Subject: [PATCH 2/2] fix: use frm instead of cur_frm (cherry picked from commit ceeb8fc9e537a42aaae1dd3b337fa8250b04a74f) --- .../accounts/doctype/payment_entry/payment_entry.js | 2 +- .../doctype/blanket_order/blanket_order.js | 2 +- erpnext/public/js/controllers/transaction.js | 2 +- erpnext/public/js/utils.js | 10 +++++----- erpnext/stock/doctype/stock_entry/stock_entry.js | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js index 62e21812301c..832b1166fba8 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.js +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js @@ -149,7 +149,7 @@ frappe.ui.form.on('Payment Entry', { }, refresh: function(frm) { - erpnext.hide_company(); + erpnext.hide_company(frm); frm.events.hide_unhide_fields(frm); frm.events.set_dynamic_labels(frm); frm.events.show_general_ledger(frm); diff --git a/erpnext/manufacturing/doctype/blanket_order/blanket_order.js b/erpnext/manufacturing/doctype/blanket_order/blanket_order.js index 7b26a14a57b2..716af85a7e88 100644 --- a/erpnext/manufacturing/doctype/blanket_order/blanket_order.js +++ b/erpnext/manufacturing/doctype/blanket_order/blanket_order.js @@ -18,7 +18,7 @@ frappe.ui.form.on('Blanket Order', { }, refresh: function(frm) { - erpnext.hide_company(); + erpnext.hide_company(frm); if (frm.doc.customer && frm.doc.docstatus === 1 && frm.doc.to_date > frappe.datetime.get_today()) { frm.add_custom_button(__("Sales Order"), function() { frappe.model.open_mapped_doc({ diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 3307e8ec381f..2e2b9dc300de 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -397,7 +397,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe refresh() { erpnext.toggle_naming_series(); - erpnext.hide_company(); + erpnext.hide_company(this.frm); this.set_dynamic_labels(); this.setup_sms(); this.setup_quality_inspection(); diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index 640b5225ff4a..2f3f4746f15d 100755 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -26,14 +26,14 @@ $.extend(erpnext, { } }, - hide_company: function() { - if(cur_frm?.fields_dict.company) { + hide_company: function(frm) { + if(frm?.fields_dict.company) { var companies = Object.keys(locals[":Company"] || {}); if(companies.length === 1) { - if(!cur_frm.doc.company) cur_frm.set_value("company", companies[0]); - cur_frm.toggle_display("company", false); + if(!frm.doc.company) frm.set_value("company", companies[0]); + frm.toggle_display("company", false); } else if(erpnext.last_selected_company) { - if(!cur_frm.doc.company) cur_frm.set_value("company", erpnext.last_selected_company); + if(!frm.doc.company) frm.set_value("company", erpnext.last_selected_company); } } }, diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 7f79f04aae9f..1b7089b95585 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -943,7 +943,7 @@ erpnext.stock.StockEntry = class StockEntry extends erpnext.stock.StockControlle if (this.frm.doc.docstatus===1 && erpnext.is_perpetual_inventory_enabled(this.frm.doc.company)) { this.show_general_ledger(); } - erpnext.hide_company(); + erpnext.hide_company(this.frm); erpnext.utils.add_item(this.frm); }