feat: ask reason for putting sales order on hold

This commit is contained in:
Mangesh-Khairnar 2019-03-05 18:15:44 +05:30
parent 83f1fbdc4e
commit bcb8b135f2
3 changed files with 72 additions and 2 deletions

View File

@ -161,7 +161,9 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
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"))
function() {
me.sales_order_on_hold();
}, __("Status"))
// close
this.frm.add_custom_button(__('Close'),
function() { me.close_sales_order() }, __("Status"))
@ -570,6 +572,37 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
});
dialog.show();
},
sales_order_on_hold: function(){
var me = this;
var d = new frappe.ui.Dialog({
title: __('Reason for Hold'),
fields: [
{
"fieldname": "reason_for_hold",
"fieldtype": "Text",
"reqd": 1,
}
],
primary_action: function() {
var data = d.get_values();
frappe.call({
method: "erpnext.selling.doctype.sales_order.sales_order.update_reason_for_hold",
args: {
data: data.reason_for_hold,
name: me.frm.doc.name
},
callback: function(r) {
if(!r.exc) {
me.frm.set_value("reason_for_hold", data.reason_for_hold);
me.update_status('Hold', 'On Hold')
d.hide();
}
}
});
}
});
d.show();
},
close_sales_order: function(){
this.frm.cscript.update_status("Close", "Closed")
},

View File

@ -3640,6 +3640,39 @@
"unique": 0,
"width": "100px"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.status === 'On Hold'",
"fieldname": "reason_for_hold",
"fieldtype": "Text",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Reason for Hold",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
@ -4113,7 +4146,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2019-02-27 19:00:29.267253",
"modified": "2019-03-04 18:43:38.354549",
"modified_by": "mangesh@iwebnotes.com",
"module": "Selling",
"name": "Sales Order",

View File

@ -960,3 +960,7 @@ def make_raw_material_request(items, company, sales_order, project=None):
material_request.run_method("set_missing_values")
material_request.submit()
return material_request
@frappe.whitelist()
def update_reason_for_hold(name, data):
frappe.db.set_value('Sales Order', name, 'reason_for_hold', data)