Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:Hiding irrelevant buttons #163

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading