diff --git a/aumms/aumms/doctype/design_analysis/design_analysis.js b/aumms/aumms/doctype/design_analysis/design_analysis.js index 89471d18..844fc58f 100644 --- a/aumms/aumms/doctype/design_analysis/design_analysis.js +++ b/aumms/aumms/doctype/design_analysis/design_analysis.js @@ -150,6 +150,7 @@ frappe.ui.form.on('Design Analysis', { }); frm.add_custom_button(__('Proceed'), () => { frm.trigger('proceed_action'); + hide_proceed_button(frm) }); }, create_bom: function(frm) { @@ -161,6 +162,7 @@ frappe.ui.form.on('Design Analysis', { callback: (r) => { if (r.message) { frappe.msgprint(__('BOM created successfully.')); + frm.remove_custom_button('Create BOM') } else { frappe.throw(__('Failed to create BOM.')); } @@ -223,4 +225,18 @@ frappe.ui.form.on('Verified Item',{ frm.set_value('gold_weight',gold_weight), frm.set_value('expected_weight',expected_weight) }, -}); \ No newline at end of file +}); + +let hide_proceed_button = function(frm) { + frappe.call({ + method: 'aumms.aumms.doctype.design_analysis.design_analysis.hide_proceed_button', + args: { + 'customer' : frm.doc.customer_name + }, + callback: (r) => { + if(r.message) { + frm.remove_custom_button('Proceed') + } + } + }) +} diff --git a/aumms/aumms/doctype/design_analysis/design_analysis.py b/aumms/aumms/doctype/design_analysis/design_analysis.py index 41410870..044299c3 100644 --- a/aumms/aumms/doctype/design_analysis/design_analysis.py +++ b/aumms/aumms/doctype/design_analysis/design_analysis.py @@ -84,3 +84,9 @@ def create_design_request(design_analysis): design_request.flags.ignore_mandatory = True design_request.save(ignore_permissions=True) frappe.msgprint("Design Request Created for the material {}".format(design_request.design_title), indicator="green", alert=1) + +@frappe.whitelist() +def hide_proceed_button(customer): + if frappe.db.exists('Design Request', {'customer' : customer}): + design_request_doc = frappe.get_doc('Design Request', {'customer' : customer}) + return 1