Skip to content

Commit

Permalink
fix:Hiding irrevelent buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashna-v committed Oct 31, 2023
1 parent 2650cf4 commit bb70758
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
18 changes: 17 additions & 1 deletion aumms/aumms/doctype/design_analysis/design_analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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.'));
}
Expand Down Expand Up @@ -223,4 +225,18 @@ frappe.ui.form.on('Verified Item',{
frm.set_value('gold_weight',gold_weight),
frm.set_value('expected_weight',expected_weight)
},
});
});

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')
}
}
})
}
6 changes: 6 additions & 0 deletions aumms/aumms/doctype/design_analysis/design_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit bb70758

Please sign in to comment.