Making the Customer DocType Submittable

Hi,

I have a use case that requires the Customer DocType to be submittable. Since one can’t use the ‘Custom Field’ or ‘Customize Form’ to change a DocType meta, I have created the following patch:

frappe.make_property_setter({‘doctype’: ‘Customer’, ‘doctype_or_field’: ‘DocType’, ‘value’: ‘1’, ‘property’: ‘is_submittable’, ‘property_type’: ‘Check’})

Though this creates the property in property_setter.json, the DocType remains unchanged. I have tried to run the migrations with no effect.

Am i mistaken in believing this can be done? If not, what am I doing wrong?

Thanks,

Morris

If you enter developer mode, you can make it submittable using the doctype form

I think you can use the workflow feature in erpnext to have submit button for your customer doctype

@cpurbaugh I had tried that but the changes are being made to customer.json in erpnext app with no way of exporting as fixtures. This is important since I need a way of sharing the changes with the other developers.

@ahmed_personal That sounds promising, Could you provide more details about how to do that?

@morrismwaura what is your usecase?

@rmehta basically, the customer has to go through an approval process. So, we have to define a workflow with the following states Pending(docstatus 0) > Approved(docstatus 1) > Accepted(docstatus 1). Once we did that, the system complained that the Customer doctype is not submittable. Of course, we can change that in the doctype form but then we will not be able to export the change as a fixture.

Add a custom field or workflow. A submittable document can’t be changed ever. So you can’t edit the name or address

1 Like

You don’t have to make the status 1, it can stay 0 the whole way through. Just change the permissions for each step if need be.

1 Like

Hello Everyone,

Sorry for bumping this 3 year old thread, but I had a similiar use case issue here.

Basically the end user wants the Customers Details to go through a series of approval process before it can be accepted in the system as “Valid Customers” .

I’ve already went ahead to create the relevant workflow approval process and also switched on “Submittable” on the forms.

Now the problem I face is, irregardless if the Customer details have been approved or not, the salesperson can still select the customer in other forms (Such as Quotations, Sales Order , Sales Invoice) even if the Customer Details’ docstate is “Rejected. Draft or Pending Approval” .

Although the same can be achieved by setting workflow state + workflow level permission, but i prefer not to do this as each user will need up to 3-4 user permissions to be able to access one single document. This coupled with a large amount of users that needs to be created will cause a large amount of work when creating accounts. Therefore, we still prefer to know if it’s possible to go the Doctype = 1 route instead.

My question is this: How do I force the system to only allow the Customer Details to be come active and “Selectable” when the docstate is 1 (not just 0, 1 and 2). ??

Any help is greatly appreciated.

Cheers,
Jonathan

Hey @Jonathan_Lee You can change your field property… go to the field property and check on allow on submit.

I guess you need a custom script to filter out only submitted Customers?

Not sure what “Allow on Submit” do, but when i tried to turn it on, an error message occurs:

“Not allowed to enable Allow on Submit for standard fields”

Any Script Reference for this? Would love to have a look at it.

Tried this

  setup: function(frm,cdt,cdn) {
		frm.set_query("customer", function() {
		return {
			filters: [
			['Customer', 'docstatus', '=', 1]
                            ]
		}
	});
},

The unsubmitted records are still showing, any idea why? No syntax error messages.

Any other solutions I can try?

I see so many examples in other forms of set_query that works.

But not sure my code doesn’t work. Anyone care to try? I’ve tried both set_query and get_query.

Also i checked the data from the database to ensure there is data.

setup: function(frm) {
	frm.custom_make_buttons = {
		'Sales Order': 'Make Sales Order'
	};		

    frm.fields_dict['customer'].get_query = function(frm){
		return {
			filters : [[
			'Customer', 'docstatus', '=', 1]]
		}
	};


	frm.set_query("customer", function() {
		return{
			filters: {
				'docstatus': 1 ,
			}
		}
	});		
},

image