From c54ccc56c7514115de1e2f42c56ad36f5874fd26 Mon Sep 17 00:00:00 2001 From: Raffael Meyer <14891507+barredterra@users.noreply.github.com> Date: Fri, 22 Aug 2025 01:09:47 +0200 Subject: [PATCH] feat: add make methods for Bank Account (#49000) * perf(make_bank_account): remove useless roundtrip to server * feat: add make methods for Bank Account Auto-fill Party Type and Party when creating a Bank Account from Customer, Supplier or Employee. --- erpnext/buying/doctype/supplier/supplier.js | 4 ++++ erpnext/public/js/utils.js | 14 +++----------- erpnext/selling/doctype/customer/customer.js | 1 + erpnext/setup/doctype/employee/employee.js | 6 ++++++ 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/erpnext/buying/doctype/supplier/supplier.js b/erpnext/buying/doctype/supplier/supplier.js index c5f46e1207d..4dda74db68d 100644 --- a/erpnext/buying/doctype/supplier/supplier.js +++ b/erpnext/buying/doctype/supplier/supplier.js @@ -64,6 +64,10 @@ frappe.ui.form.on("Supplier", { }, }; }); + + frm.make_methods = { + "Bank Account": () => erpnext.utils.make_bank_account(frm.doc.doctype, frm.doc.name), + }; }, refresh: function (frm) { diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index 65f357bbba9..eb02cbce4c7 100755 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -213,17 +213,9 @@ $.extend(erpnext.utils, { }, make_bank_account: function (doctype, docname) { - frappe.call({ - method: "erpnext.accounts.doctype.bank_account.bank_account.make_bank_account", - args: { - doctype: doctype, - docname: docname, - }, - freeze: true, - callback: function (r) { - var doclist = frappe.model.sync(r.message); - frappe.set_route("Form", doclist[0].doctype, doclist[0].name); - }, + frappe.new_doc("Bank Account", { + party_type: doctype, + party: docname, }); }, diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js index 816c45f15f8..d314c878cc2 100644 --- a/erpnext/selling/doctype/customer/customer.js +++ b/erpnext/selling/doctype/customer/customer.js @@ -33,6 +33,7 @@ frappe.ui.form.on("Customer", { frm: frm, }), "Pricing Rule": () => erpnext.utils.make_pricing_rule(frm.doc.doctype, frm.doc.name), + "Bank Account": () => erpnext.utils.make_bank_account(frm.doc.doctype, frm.doc.name), }; frm.add_fetch("lead_name", "company_name", "customer_name"); diff --git a/erpnext/setup/doctype/employee/employee.js b/erpnext/setup/doctype/employee/employee.js index f6b4a12a760..22079e94075 100755 --- a/erpnext/setup/doctype/employee/employee.js +++ b/erpnext/setup/doctype/employee/employee.js @@ -21,6 +21,12 @@ erpnext.setup.EmployeeController = class EmployeeController extends frappe.ui.fo }; frappe.ui.form.on("Employee", { + setup: function (frm) { + frm.make_methods = { + "Bank Account": () => erpnext.utils.make_bank_account(frm.doc.doctype, frm.doc.name), + }; + }, + onload: function (frm) { frm.set_query("department", function () { return {