Tanuj
November 25, 2015, 9:22am
1
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) {
Tanuj
November 25, 2015, 9:43am
3
@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
})
})
}
});
Tanuj
November 25, 2015, 10:09am
6
@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.
Tanuj
November 25, 2015, 10:17am
8
Alright, Thank you so much!
rmehta
November 26, 2015, 5:32am
9
@Tanuj what is the use-case? Making a Customer from Lead?
Tanuj
November 26, 2015, 8:48am
10
@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.
Tanuj
November 26, 2015, 11:48am
11
@rmehta Any suggestions on this? Or would I have to do this through the custom app method?
Thanks!
rmehta
November 27, 2015, 6:45am
12
@Tanuj there is a “Make Customer” button in Lead, could be in quotation too.
Send your pull-request. Will help you over there
Tanuj
November 27, 2015, 9:37am
13
@rmehta Alright!
Thank you so much.