From 3a4ba0c7902c726c741e26973492e64fa39d26cc Mon Sep 17 00:00:00 2001 From: iamkhanraheel Date: Sat, 29 Mar 2025 03:59:57 +0530 Subject: [PATCH 1/3] fix: fetch customer related data in making payment entry from customer --- erpnext/selling/doctype/customer/customer.js | 6 +++++ erpnext/selling/doctype/customer/customer.py | 27 ++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js index 50248a985aa..cfe3af37f89 100644 --- a/erpnext/selling/doctype/customer/customer.js +++ b/erpnext/selling/doctype/customer/customer.js @@ -8,6 +8,7 @@ frappe.ui.form.on("Customer", { Quotation: "Quotation", "Sales Order": "Sales Order", "Pricing Rule": "Pricing Rule", + "Payment Entry": "Payment Entry", }; frm.make_methods = { Quotation: () => @@ -26,6 +27,11 @@ frappe.ui.form.on("Customer", { method: "erpnext.selling.doctype.customer.customer.make_opportunity", frm: frm, }), + "Payment Entry": () => + frappe.model.open_mapped_doc({ + method: "erpnext.selling.doctype.customer.customer.make_payment_entry", + frm: cur_frm, + }), "Pricing Rule": () => erpnext.utils.make_pricing_rule(frm.doc.doctype, frm.doc.name), }; diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index 21593f1bb23..61c9e9353ca 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -438,6 +438,33 @@ def make_opportunity(source_name, target_doc=None): return target_doc +@frappe.whitelist() +def make_payment_entry(source_name, target_doc=None): + print(source_name, target_doc) + + def set_missing_values(source, target): + _set_missing_values(source, target) + + target_doc = get_mapped_doc( + "Customer", + source_name, + { + "Customer": { + "doctype": "Payment Entry", + "field_map": { + "name": "party", + }, + } + }, + target_doc, + set_missing_values, + ) + target_doc.party_type = "Customer" + target_doc.party_name = target_doc.party + + return target_doc + + def _set_missing_values(source, target): address = frappe.get_all( "Dynamic Link", From 42847014425e99f78b06e24dc4969cb8ffcbdbd7 Mon Sep 17 00:00:00 2001 From: iamkhanraheel Date: Sat, 29 Mar 2025 06:15:22 +0530 Subject: [PATCH 2/3] refactor: remove print func --- erpnext/selling/doctype/customer/customer.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index 61c9e9353ca..869dc944a3b 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -440,8 +440,6 @@ def make_opportunity(source_name, target_doc=None): @frappe.whitelist() def make_payment_entry(source_name, target_doc=None): - print(source_name, target_doc) - def set_missing_values(source, target): _set_missing_values(source, target) From 19279dffea1bae7e903b413a07ab7c154846cb47 Mon Sep 17 00:00:00 2001 From: iamkhanraheel Date: Sat, 29 Mar 2025 16:41:28 +0530 Subject: [PATCH 3/3] fix: change cur_frm to frm --- erpnext/selling/doctype/customer/customer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js index cfe3af37f89..18c432db91b 100644 --- a/erpnext/selling/doctype/customer/customer.js +++ b/erpnext/selling/doctype/customer/customer.js @@ -30,7 +30,7 @@ frappe.ui.form.on("Customer", { "Payment Entry": () => frappe.model.open_mapped_doc({ method: "erpnext.selling.doctype.customer.customer.make_payment_entry", - frm: cur_frm, + frm: frm, }), "Pricing Rule": () => erpnext.utils.make_pricing_rule(frm.doc.doctype, frm.doc.name), };