ERPNext Foundation ERPNext Cloud Chat Blog Discuss Frappé* Donate

Cur_frm.doc.close() not working in custom script for Purchase Order


#1

Hi All,
when i was trying to do actions(insert,save,cancel…) for Purchase Order doc is working fine but i’m not able to perform close() action.
Any suggestions?


#2

what you want to close??


#3

I am trying to change the status as Closed. Please find attached one


#4

check below code

 frappe.ui.form.on("Branding Requisition", {
    	"refresh": function(frm) {
    		if(frm.doc.status!=="Closed") {
    			frm.add_custom_button(__("Close"), function() {
    				frm.set_value("status", "Closed");
    				frm.save();
    			});
    		} else {
    			frm.add_custom_button(__("Reopen"), function() {
    				frm.set_value("status", "Open");
    				frm.save();
    			});
    		}
    	}
    });

#5

Hii @Maheshwari_Bhavesh
I tried with below lines:
frm.set_value(“status”, “Closed”);
frm.save();

I’m getting below error:
DocstatusTransitionError: Cannot change docstatus from 1 to 0