fix(ux): Reserve Stock button behaviour in SO

This commit is contained in:
s-aga-r 2023-03-23 13:34:40 +05:30
parent f8c477ca5c
commit 1ccdf588e2

View File

@ -47,17 +47,7 @@ frappe.ui.form.on("Sales Order", {
frm.set_df_property('packed_items', 'cannot_add_rows', true);
frm.set_df_property('packed_items', 'cannot_delete_rows', true);
frappe.db.get_single_value("Stock Settings", "enable_stock_reservation").then((value) => {
if (value) {
frappe.db.get_single_value("Stock Settings", "reserve_stock_on_sales_order_submission").then((value) => {
if (value) {
frm.set_value("reserve_stock", 1);
}
})
} else {
frm.set_df_property("reserve_stock", "read_only", 1);
}
})
},
refresh: function(frm) {
if(frm.doc.docstatus === 1 && frm.doc.status !== 'Closed'
@ -72,8 +62,25 @@ frappe.ui.form.on("Sales Order", {
});
}
if (frm.doc.docstatus === 0 && frm.doc.is_internal_customer) {
frm.events.get_items_from_internal_purchase_order(frm);
if (frm.doc.docstatus === 0) {
if (frm.doc.is_internal_customer) {
frm.events.get_items_from_internal_purchase_order(frm);
}
frappe.db.get_single_value("Stock Settings", "enable_stock_reservation").then((value) => {
if (value) {
frappe.db.get_single_value("Stock Settings", "reserve_stock_on_sales_order_submission").then((value) => {
if (value) {
frm.set_value("reserve_stock", 1);
} else {
frm.set_value("reserve_stock", 0);
}
})
} else {
frm.set_value("reserve_stock", 0);
frm.set_df_property("reserve_stock", "read_only", 1);
}
})
}
},