fix: custom buttons are hidden if order type of SO is customised (#21397)
diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js
index 61aa608..3c1ffe9 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.js
+++ b/erpnext/selling/doctype/sales_order/sales_order.js
@@ -148,9 +148,14 @@
}
this.frm.add_custom_button(__('Pick List'), () => this.create_pick_list(), __('Create'));
+
+ const order_is_a_sale = ["Sales", "Shopping Cart"].indexOf(doc.order_type) !== -1;
+ const order_is_maintenance = ["Maintenance"].indexOf(doc.order_type) !== -1;
+ // order type has been customised then show all the action buttons
+ const order_is_a_custom_sale = ["Sales", "Shopping Cart", "Maintenance"].indexOf(doc.order_type) === -1;
// delivery note
- if(flt(doc.per_delivered, 6) < 100 && ["Sales", "Shopping Cart"].indexOf(doc.order_type)!==-1 && allow_delivery) {
+ if(flt(doc.per_delivered, 6) < 100 && (order_is_a_sale || order_is_a_custom_sale) && allow_delivery) {
this.frm.add_custom_button(__('Delivery Note'), () => this.make_delivery_note_based_on_delivery_date(), __('Create'));
this.frm.add_custom_button(__('Work Order'), () => this.make_work_order(), __('Create'));
}
@@ -161,8 +166,7 @@
}
// material request
- if(!doc.order_type || ["Sales", "Shopping Cart"].indexOf(doc.order_type)!==-1
- && flt(doc.per_delivered, 6) < 100) {
+ if(!doc.order_type || (order_is_a_sale || order_is_a_custom_sale) && flt(doc.per_delivered, 6) < 100) {
this.frm.add_custom_button(__('Material Request'), () => this.make_material_request(), __('Create'));
this.frm.add_custom_button(__('Request for Raw Materials'), () => this.make_raw_material_request(), __('Create'));
}
@@ -171,14 +175,13 @@
this.frm.add_custom_button(__('Purchase Order'), () => this.make_purchase_order(), __('Create'));
// maintenance
- if(flt(doc.per_delivered, 2) < 100 &&
- ["Sales", "Shopping Cart"].indexOf(doc.order_type)===-1) {
+ if(flt(doc.per_delivered, 2) < 100 && (order_is_maintenance || order_is_a_custom_sale)) {
this.frm.add_custom_button(__('Maintenance Visit'), () => this.make_maintenance_visit(), __('Create'));
this.frm.add_custom_button(__('Maintenance Schedule'), () => this.make_maintenance_schedule(), __('Create'));
}
// project
- if(flt(doc.per_delivered, 2) < 100 && ["Sales", "Shopping Cart"].indexOf(doc.order_type)!==-1 && allow_delivery) {
+ if(flt(doc.per_delivered, 2) < 100 && (order_is_a_sale || order_is_a_custom_sale) && allow_delivery) {
this.frm.add_custom_button(__('Project'), () => this.make_project(), __('Create'));
}