Work Flow UI integration in ERPnext

@ramielian add the states Accepted and Rejected in your Workflow and add this custom script in the target doctype, dont forget of replace {doctype} by the name of your doctype!

This script listen to workflow state to save a description of the Rejection

frappe.ui.form.on("{DocType}", "after_save", function(frm, cdt, cdn){
		if (frm.doc.workflow_state && frm.doc.workflow_state.indexOf("Rejected") > 0){
			frappe.prompt([
				{
					fieldtype: 'Small Text',
					reqd: true,
					fieldname: 'reason'
				}],
				function(args){
					validated = true;
					frappe.call({
						method: 'frappe.core.doctype.communication.email.make',
						args: {
							doctype: frm.doctype,
							name: frm.docname,
							subject: format(__('Reason for {0}'), [frm.doc.workflow_state]),
							content: args.reason,
							send_mail: false,
							send_me_a_copy: false,
							communication_medium: 'Other',
							sent_or_received: 'Sent'
						},
						callback: function(res){
							if (res && !res.exc){
								frappe.call({
									method: 'frappe.client.set_value',
									args: {
										doctype: frm.doctype,
										name: frm.docname,
										fieldname: 'rejection_reason',
										value: frm.doc.rejection_reason ?
											[frm.doc.rejection_reason, frm.doc.workflow_state].join('\n') : frm.doc.workflow_state
									},
									callback: function(res){
										if (res && !res.exc){
											frm.reload_doc();
										}
									}
								});
							}
						}
					});
				},
				__('Reason for ') + frm.doc.workflow_state,
				__('End as Rejected')
			)
		}
	});