fix: custom buttons are hidden if order type of SO is customised (#21397)
This commit is contained in:
parent
55102f455f
commit
8952ac1ab4
@ -148,9 +148,14 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.frm.add_custom_button(__('Pick List'), () => this.create_pick_list(), __('Create'));
|
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
|
// 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(__('Delivery Note'), () => this.make_delivery_note_based_on_delivery_date(), __('Create'));
|
||||||
this.frm.add_custom_button(__('Work Order'), () => this.make_work_order(), __('Create'));
|
this.frm.add_custom_button(__('Work Order'), () => this.make_work_order(), __('Create'));
|
||||||
}
|
}
|
||||||
@ -161,8 +166,7 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// material request
|
// material request
|
||||||
if(!doc.order_type || ["Sales", "Shopping Cart"].indexOf(doc.order_type)!==-1
|
if(!doc.order_type || (order_is_a_sale || order_is_a_custom_sale) && flt(doc.per_delivered, 6) < 100) {
|
||||||
&& flt(doc.per_delivered, 6) < 100) {
|
|
||||||
this.frm.add_custom_button(__('Material Request'), () => this.make_material_request(), __('Create'));
|
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'));
|
this.frm.add_custom_button(__('Request for Raw Materials'), () => this.make_raw_material_request(), __('Create'));
|
||||||
}
|
}
|
||||||
@ -171,14 +175,13 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
|
|||||||
this.frm.add_custom_button(__('Purchase Order'), () => this.make_purchase_order(), __('Create'));
|
this.frm.add_custom_button(__('Purchase Order'), () => this.make_purchase_order(), __('Create'));
|
||||||
|
|
||||||
// maintenance
|
// maintenance
|
||||||
if(flt(doc.per_delivered, 2) < 100 &&
|
if(flt(doc.per_delivered, 2) < 100 && (order_is_maintenance || order_is_a_custom_sale)) {
|
||||||
["Sales", "Shopping Cart"].indexOf(doc.order_type)===-1) {
|
|
||||||
this.frm.add_custom_button(__('Maintenance Visit'), () => this.make_maintenance_visit(), __('Create'));
|
this.frm.add_custom_button(__('Maintenance Visit'), () => this.make_maintenance_visit(), __('Create'));
|
||||||
this.frm.add_custom_button(__('Maintenance Schedule'), () => this.make_maintenance_schedule(), __('Create'));
|
this.frm.add_custom_button(__('Maintenance Schedule'), () => this.make_maintenance_schedule(), __('Create'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// project
|
// 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'));
|
this.frm.add_custom_button(__('Project'), () => this.make_project(), __('Create'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user