Create 'Make Payment' button on custom Doctype

Hai Everyone,
I have created a custom doctype for entering expenses of Subcontractor.
If the form is saved and submitted, I want to do the ‘Make’ button visible and it shows options ‘Make Payment’ and ‘Make Completion Certificate’.
The ‘Make’ button is like in the cases of Lead/Opportunity/Sales order etc.

I am in trouble, as i don’t know where to do it in the custom doctype.
I see in Lead.js the code should be inside,
erpnext.LeadController = frappe.ui.form.Controller.extend({
similarily in Quotation.js, it is inside
erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({

So howis it possible it in custom doctype?

Add custom button and call your custom function.

Let me know, if you have any issue in creating button and calling your script

@kolate_sambhaji. Thank you. Surely, will let you know soon.

@kolate_sambhaji. It works!!! Thank you so much

But, I want to show this button once it is submitted.
Is anything wrong in my code shown below: Can you help me please?

frappe.ui.form.on(‘Subcontract’, {
refresh: function(doc,dt,dn) {

	if(doc.docstatus=='Submitted') {
	//	if(doc.status != 'Closed') {
			cur_frm.add_custom_button(__('Payment'), cur_frm.cscript.make_bank_entry, __("Make"));
			cur_frm.add_custom_button(__('Completion Certificate'), cur_frm.cscript.make_completion_certificate, __("Make"));
	//	}"Make"));	

make_completion_certificate: function() {
		method: "erpnext.projects.doctype.subcontractor_completion_certificates.opportunity.make_certificate",
		frm: cur_frm

make_bank_entry: function() {
		method: "erpnext.accounts.doctype.journal_entry.journal_entry.get_payment_entry_against_order",
		args: {
			"dt": "Sales Order",
		callback: function(r) {
			var doclist = frappe.model.sync(r.message);
			frappe.set_route("Form", doclist[0].doctype, doclist[0].name);


doc.docstatus == 1 to check submitted document.

@kolate_sambhaji I tried it also… but it doesn’t work for me.
Status is shown “undefined” !

@Amalendu share your code


The code was…

frappe.ui.form.on(‘Subcontract’, {
refresh: function(doc,dt,dn) {
if (doc.docstatus==1) {
// if(doc.status != ‘Closed’) {
cur_frm.add_custom_button(__(‘Payment’), cur_frm.cscript.make_bank_entry, (“Make”));
(‘Completion Certificate’), cur_frm.cscript.make_completion_certificate, (“Make”));
// }

alert(cur_frm.doc.docstatus) ;

Shows correct status!! Thank you

You need to write

refresh: function(frm,dt,dn) {
then you can access status using frm.doc.status

1 Like

oh… understood…
Thank you…