i have made a custom doctype it’s name is clients like customers
i want to add to add option in make button make to make a new client
Hi, @fatheyabdelslam
not possible through custom script. you can add button of that doctype on Lead Dashboard.
thank you for your replay
do you say i can’t do such thing ?
Are you sure? I’m pretty sure you can, I’ve done auto-document-creation from a custom script before.
put this is custom script
frappe.ui.form.on("Lead", "refresh", function(frm, cdt, cdn) {
frm.add_custom_button(__("Client"), this.creat_client, __("Make"));
});
you need to make create_client method like below create_customer
create_customer: function() {
frappe.model.open_mapped_doc({
method: "erpnext.crm.doctype.lead.lead.make_customer",
frm: cur_frm
})
},
share your custom script code
frappe.ui.form.on("Lead", "refresh", function(frm, cdt, cdn) {
frm.add_custom_button(__("Risk Profile"), this.creat_client, __("Make"));
create_risk_profile: function() {
frappe.model.open_mapped_doc({
method: "erpnext.crm.doctype.lead.lead.make_risk_profile",
frm: cur_frm
});
},
});
Thank You
try this:
frappe.ui.form.on("Lead", {
refresh:function(frm, cdt, cdn){
frm.add_custom_button(__('Risk Profile'),
function() {
frappe.model.open_mapped_doc({
method: "erpnext.crm.doctype.lead.lead.make_risk_profile",
frm: cur_frm
});
}, __("Make"));
},
})
share your python method:
erpnext.crm.doctype.lead.lead.make_risk_profile
@Maheshwari_Bhavesh
I don’t have a back-end access.
only i am working through Custom Script.
Note :-
- I was Created a Doctype Risk Profile.
- Module Name CRM.
Thank You
you need to make python method like below:
def make_customer(source_name, target_doc=None, ignore_permissions=False):
def set_missing_values(source, target):
if source.company_name:
target.customer_type = "Company"
target.customer_name = source.company_name
else:
target.customer_type = "Individual"
target.customer_name = source.lead_name
target.customer_group = frappe.db.get_default("Customer Group")
doclist = get_mapped_doc("Lead", source_name,
{"Lead": {
"doctype": "Customer",
"field_map": {
"name": "lead_name",
"company_name": "customer_name",
"contact_no": "phone_1",
"fax": "fax_1"
}
}}, target_doc, set_missing_values, ignore_permissions=ignore_permissions)
return doclist
Hi @Maheshwari_Bhavesh
through Custom Script it is possible or not because i don’t have back-end code access.
Thank You
possible check this :
Hi @hari.kishor
As far as I have understood from the conversation on this thread, I presume you want to add a Client button under the Make button on Lead doctype which would route you to your custom doctype’s new form.
You don’t need to add any back-end code. Paste the below code in the Custom Script for Lead doctype.
frappe.ui.form.on("Lead", {
refresh: function(frm) {
frm.add_custom_button(__("Client"), function() {
frappe.route_options = {
"client_name": frm.doc.lead_name
};
frappe.new_doc("[your_custom_doctype_name]");
}, __("Make"));
}
});
Here, under the route_options
you can add the fields which you would like to copy from the Lead Doctype to your custom doctype and define according to that.
Hope this helps.