feat: add resume funtionality for sales order on hold
This commit is contained in:
parent
86e650c1ed
commit
3ebeac13e9
@ -33,7 +33,8 @@ frappe.ui.form.on("Sales Order", {
|
||||
})
|
||||
},
|
||||
refresh: function(frm) {
|
||||
if(frm.doc.docstatus == 1 && frm.doc.status == 'To Deliver and Bill') {
|
||||
if(frm.doc.docstatus == 1 && frm.doc.status != 'Closed'
|
||||
&& flt(frm.doc.per_delivered) < 100 && flt(frm.doc.per_billed) < 100) {
|
||||
frm.add_custom_button(__('Update Items'), () => {
|
||||
erpnext.utils.update_child_items({
|
||||
frm: frm,
|
||||
@ -114,67 +115,110 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
|
||||
var allow_delivery = false;
|
||||
|
||||
if(doc.docstatus==1) {
|
||||
if(this.frm.has_perm("submit")) {
|
||||
if(doc.status === 'On Hold') {
|
||||
// un-hold
|
||||
this.frm.add_custom_button(__('Resume'), function() {
|
||||
me.frm.cscript.update_status('Resume', 'Draft')
|
||||
}, __("Status"));
|
||||
|
||||
if(flt(doc.per_delivered, 6) < 100 || flt(doc.per_billed) < 100) {
|
||||
// close
|
||||
this.frm.add_custom_button(__('Close'),
|
||||
function() { me.close_sales_order() }, __("Status"))
|
||||
}
|
||||
}
|
||||
else if(doc.status === 'Closed') {
|
||||
// un-close
|
||||
this.frm.add_custom_button(__('Re-open'), function() {
|
||||
me.frm.cscript.update_status('Re-open', 'Draft')
|
||||
}, __("Status"));
|
||||
}
|
||||
}
|
||||
if(doc.status != 'Closed') {
|
||||
if(doc.status != 'On Hold') {
|
||||
for (var i in this.frm.doc.items) {
|
||||
var item = this.frm.doc.items[i];
|
||||
if(item.delivered_by_supplier === 1 || item.supplier){
|
||||
if(item.qty > flt(item.ordered_qty)
|
||||
&& item.qty > flt(item.delivered_qty)) {
|
||||
allow_purchase = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (var i in this.frm.doc.items) {
|
||||
var item = this.frm.doc.items[i];
|
||||
if(item.delivered_by_supplier === 1 || item.supplier){
|
||||
if(item.qty > flt(item.ordered_qty)
|
||||
&& item.qty > flt(item.delivered_qty)) {
|
||||
allow_purchase = true;
|
||||
if (item.delivered_by_supplier===0) {
|
||||
if(item.qty > flt(item.delivered_qty)) {
|
||||
allow_delivery = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (allow_delivery && allow_purchase) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.delivered_by_supplier===0) {
|
||||
if(item.qty > flt(item.delivered_qty)) {
|
||||
allow_delivery = true;
|
||||
if (this.frm.has_perm("submit")) {
|
||||
if(flt(doc.per_delivered, 6) < 100 || flt(doc.per_billed) < 100) {
|
||||
// hold
|
||||
this.frm.add_custom_button(__('Hold'),
|
||||
function() { me.update_status('Hold', 'On Hold') }, __("Status"))
|
||||
// close
|
||||
this.frm.add_custom_button(__('Close'),
|
||||
function() { me.close_sales_order() }, __("Status"))
|
||||
}
|
||||
}
|
||||
|
||||
if (allow_delivery && allow_purchase) {
|
||||
break;
|
||||
// delivery note
|
||||
if(flt(doc.per_delivered, 6) < 100 && ["Sales", "Shopping Cart"].indexOf(doc.order_type)!==-1 && allow_delivery) {
|
||||
this.frm.add_custom_button(__('Delivery'),
|
||||
function() { me.make_delivery_note_based_on_delivery_date(); }, __('Create'));
|
||||
this.frm.add_custom_button(__('Work Order'),
|
||||
function() { me.make_work_order() }, __('Create'));
|
||||
|
||||
this.frm.page.set_inner_btn_group_as_primary(__('Create'));
|
||||
}
|
||||
|
||||
// sales invoice
|
||||
if(flt(doc.per_billed, 6) < 100) {
|
||||
this.frm.add_custom_button(__('Invoice'),
|
||||
function() { me.make_sales_invoice() }, __('Create'));
|
||||
}
|
||||
|
||||
// material request
|
||||
if(!doc.order_type || ["Sales", "Shopping Cart"].indexOf(doc.order_type)!==-1
|
||||
&& flt(doc.per_delivered, 6) < 100) {
|
||||
this.frm.add_custom_button(__('Material Request'),
|
||||
function() { me.make_material_request() }, __('Create'));
|
||||
this.frm.add_custom_button(__('Request for Raw Materials'),
|
||||
function() { me.make_raw_material_request() }, __('Create'));
|
||||
}
|
||||
|
||||
// make purchase order
|
||||
if(flt(doc.per_delivered, 6) < 100 && allow_purchase) {
|
||||
this.frm.add_custom_button(__('Purchase Order'),
|
||||
function() { me.make_purchase_order() }, __('Create'));
|
||||
}
|
||||
// maintenance
|
||||
if(flt(doc.per_delivered, 2) < 100 &&
|
||||
["Sales", "Shopping Cart"].indexOf(doc.order_type)===-1) {
|
||||
this.frm.add_custom_button(__('Maintenance Visit'),
|
||||
function() { me.make_maintenance_visit() }, __('Create'));
|
||||
this.frm.add_custom_button(__('Maintenance Schedule'),
|
||||
function() { me.make_maintenance_schedule() }, __('Create'));
|
||||
}
|
||||
|
||||
// project
|
||||
if(flt(doc.per_delivered, 2) < 100 && ["Sales", "Shopping Cart"].indexOf(doc.order_type)!==-1 && allow_delivery) {
|
||||
this.frm.add_custom_button(__('Project'),
|
||||
function() { me.make_project() }, __('Create'));
|
||||
}
|
||||
|
||||
if(!doc.auto_repeat) {
|
||||
this.frm.add_custom_button(__('Subscription'), function() {
|
||||
erpnext.utils.make_subscription(doc.doctype, doc.name)
|
||||
}, __('Create'))
|
||||
}
|
||||
}
|
||||
|
||||
if (this.frm.has_perm("submit")) {
|
||||
// close
|
||||
if(flt(doc.per_delivered, 6) < 100 || flt(doc.per_billed) < 100) {
|
||||
this.frm.add_custom_button(__('Close'),
|
||||
function() { me.close_sales_order() }, __("Status"))
|
||||
}
|
||||
}
|
||||
|
||||
// delivery note
|
||||
if(flt(doc.per_delivered, 6) < 100 && ["Sales", "Shopping Cart"].indexOf(doc.order_type)!==-1 && allow_delivery) {
|
||||
this.frm.add_custom_button(__('Delivery'),
|
||||
function() { me.make_delivery_note_based_on_delivery_date(); }, __('Create'));
|
||||
this.frm.add_custom_button(__('Work Order'),
|
||||
function() { me.make_work_order() }, __('Create'));
|
||||
|
||||
this.frm.page.set_inner_btn_group_as_primary(__('Create'));
|
||||
}
|
||||
|
||||
// sales invoice
|
||||
if(flt(doc.per_billed, 6) < 100) {
|
||||
this.frm.add_custom_button(__('Invoice'),
|
||||
function() { me.make_sales_invoice() }, __('Create'));
|
||||
}
|
||||
|
||||
// material request
|
||||
if(!doc.order_type || ["Sales", "Shopping Cart"].indexOf(doc.order_type)!==-1
|
||||
&& flt(doc.per_delivered, 6) < 100) {
|
||||
this.frm.add_custom_button(__('Material Request'),
|
||||
function() { me.make_material_request() }, __('Create'));
|
||||
this.frm.add_custom_button(__('Request for Raw Materials'),
|
||||
function() { me.make_raw_material_request() }, __('Create'));
|
||||
}
|
||||
|
||||
// make purchase order
|
||||
if(flt(doc.per_delivered, 6) < 100 && allow_purchase) {
|
||||
this.frm.add_custom_button(__('Purchase Order'),
|
||||
function() { me.make_purchase_order() }, __('Create'));
|
||||
}
|
||||
|
||||
// payment request
|
||||
if(flt(doc.per_billed)==0) {
|
||||
this.frm.add_custom_button(__('Payment Request'),
|
||||
@ -182,35 +226,6 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
|
||||
this.frm.add_custom_button(__('Payment'),
|
||||
function() { me.make_payment_entry() }, __('Create'));
|
||||
}
|
||||
|
||||
// maintenance
|
||||
if(flt(doc.per_delivered, 2) < 100 &&
|
||||
["Sales", "Shopping Cart"].indexOf(doc.order_type)===-1) {
|
||||
this.frm.add_custom_button(__('Maintenance Visit'),
|
||||
function() { me.make_maintenance_visit() }, __('Create'));
|
||||
this.frm.add_custom_button(__('Maintenance Schedule'),
|
||||
function() { me.make_maintenance_schedule() }, __('Create'));
|
||||
}
|
||||
|
||||
// project
|
||||
if(flt(doc.per_delivered, 2) < 100 && ["Sales", "Shopping Cart"].indexOf(doc.order_type)!==-1 && allow_delivery) {
|
||||
this.frm.add_custom_button(__('Project'),
|
||||
function() { me.make_project() }, __('Create'));
|
||||
}
|
||||
|
||||
if(!doc.auto_repeat) {
|
||||
this.frm.add_custom_button(__('Subscription'), function() {
|
||||
erpnext.utils.make_subscription(doc.doctype, doc.name)
|
||||
}, __('Create'))
|
||||
}
|
||||
|
||||
} else {
|
||||
if (this.frm.has_perm("submit")) {
|
||||
// un-close
|
||||
this.frm.add_custom_button(__('Re-open'), function() {
|
||||
me.frm.cscript.update_status('Re-open', 'Draft')
|
||||
}, __("Status"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -574,4 +589,4 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
|
||||
});
|
||||
}
|
||||
});
|
||||
$.extend(cur_frm.cscript, new erpnext.selling.SalesOrderController({frm: cur_frm}));
|
||||
$.extend(cur_frm.cscript, new erpnext.selling.SalesOrderController({frm: cur_frm}));
|
@ -5,6 +5,9 @@ frappe.listview_settings['Sales Order'] = {
|
||||
if (doc.status === "Closed") {
|
||||
return [__("Closed"), "green", "status,=,Closed"];
|
||||
|
||||
} else if (doc.status === "On Hold") {
|
||||
// on hold
|
||||
return [__("On Hold"), "orange", "status,=,On Hold"];
|
||||
} else if (doc.order_type !== "Maintenance"
|
||||
&& flt(doc.per_delivered, 6) < 100 && frappe.datetime.get_diff(doc.delivery_date) < 0) {
|
||||
// not delivered & overdue
|
||||
|
Loading…
x
Reference in New Issue
Block a user