From bb707589b5ae962184f0a4459ab29e80144795a9 Mon Sep 17 00:00:00 2001 From: Ashna-v Date: Tue, 31 Oct 2023 11:17:43 +0530 Subject: [PATCH] fix:Hiding irrevelent buttons --- .../doctype/design_analysis/design_analysis.js | 18 +++++++++++++++++- .../doctype/design_analysis/design_analysis.py | 6 ++++++ 2 files changed, 23 insertions(+), 1 deletion(-) 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