From 0700063379bf2abbc950c17daa17395e5407976e Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Mon, 20 Mar 2023 23:55:33 +0530 Subject: [PATCH] chore: add `Reserve Stock` check field in Sales Order --- erpnext/selling/doctype/sales_order/sales_order.js | 12 ++++++++++++ erpnext/selling/doctype/sales_order/sales_order.json | 10 +++++++++- .../doctype/sales_order_item/sales_order_item.json | 10 +++++++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js index 449d461561..0a385c590c 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.js +++ b/erpnext/selling/doctype/sales_order/sales_order.js @@ -46,6 +46,18 @@ 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' diff --git a/erpnext/selling/doctype/sales_order/sales_order.json b/erpnext/selling/doctype/sales_order/sales_order.json index ccea8407ab..40cb17df05 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.json +++ b/erpnext/selling/doctype/sales_order/sales_order.json @@ -46,6 +46,7 @@ "scan_barcode", "column_break_28", "set_warehouse", + "reserve_stock", "items_section", "items", "section_break_31", @@ -1637,13 +1638,20 @@ "fieldname": "named_place", "fieldtype": "Data", "label": "Named Place" + }, + { + "default": "0", + "fieldname": "reserve_stock", + "fieldtype": "Check", + "label": "Reserve Stock", + "no_copy": 1 } ], "icon": "fa fa-file-text", "idx": 105, "is_submittable": 1, "links": [], - "modified": "2022-12-12 18:34:00.681780", + "modified": "2023-03-20 23:51:04.036757", "modified_by": "Administrator", "module": "Selling", "name": "Sales Order", diff --git a/erpnext/selling/doctype/sales_order_item/sales_order_item.json b/erpnext/selling/doctype/sales_order_item/sales_order_item.json index d0dabad5c9..8786f6b904 100644 --- a/erpnext/selling/doctype/sales_order_item/sales_order_item.json +++ b/erpnext/selling/doctype/sales_order_item/sales_order_item.json @@ -10,6 +10,7 @@ "item_code", "customer_item_code", "ensure_delivery_based_on_produced_serial_no", + "reserve_stock", "col_break1", "delivery_date", "item_name", @@ -859,12 +860,19 @@ "fieldname": "material_request_item", "fieldtype": "Data", "label": "Material Request Item" + }, + { + "default": "1", + "depends_on": "eval: parent.reserve_stock", + "fieldname": "reserve_stock", + "fieldtype": "Check", + "label": "Reserve Stock" } ], "idx": 1, "istable": 1, "links": [], - "modified": "2022-12-25 02:51:10.247569", + "modified": "2023-03-20 23:43:15.099790", "modified_by": "Administrator", "module": "Selling", "name": "Sales Order Item",