diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js index 33f5b312460..816c45f15f8 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: 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..869dc944a3b 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -438,6 +438,31 @@ def make_opportunity(source_name, target_doc=None): return target_doc +@frappe.whitelist() +def make_payment_entry(source_name, target_doc=None): + 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",