Make Customer Button from Quotation

Hi!

Im trying to add a custom button “Make Customer” to the quotation when it’s status is 1, and . But the following code is stoping the quotation page from loading. Can someone please help?

frappe.ui.form.on("Event", "refresh", function(frm) {
if(cur_frm.doc.docstatus == 1 && cur_frm.doc.status!=='Lost' && cur_frm.doc.quotation_to == 'Lead') {
frm.add_custom_button(__("Create Customer"), function() {
 frappe.model.open_mapped_doc({
                        method = "erpnext.selling.doctype.quotation.quotation._make_customer",
                        frm = cur_frm
                })
}}
}

Change Event to Quotation and write script on onload event.

frappe.ui.form.on("Quotation", "onload", function(frm) {

@kolate_sambhaji

Don’t know how i missed that. Thanks!

Unfortunately, I’m still getting the same problem

can you share console log

@Tanuj

try this working script, you have to use : instead of = in argument list

frappe.ui.form.on("Quotation", "refresh", function(frm){
    if(cur_frm.doc.docstatus == 1 && cur_frm.doc.status!=='Lost' && cur_frm.doc.quotation_to == 'Lead') {
      frm.add_custom_button(__("Create Customer"), function() {
        frappe.model.open_mapped_doc({
                        method : "erpnext.selling.doctype.quotation.quotation._make_customer",
                        frm : cur_frm
                })
         })
    }
});

@kolate_sambhaji

The script worked! Thank you so much!

Now, another problem has arisen. I get a message “Not Permitted” when I click on the Create Customer button.
Any clue why that would happen?

Thank You!

@Tanuj I am getting same message “Not Permitted”

You can create your custom method make_customer and write it into your custom app.

Alright, Thank you so much!

@Tanuj what is the use-case? Making a Customer from Lead?

@rmehta
Since I can’t make an SO from the Quotation without the Lead being a Customer, I wanted to add a "Make Customer " Button after the Quotation has been submitted.

@rmehta Any suggestions on this? Or would I have to do this through the custom app method?

Thanks!

@Tanuj there is a “Make Customer” button in Lead, could be in quotation too.

Send your pull-request. Will help you over there :smile:

@rmehta Alright!
Thank you so much.