refactor: rename field Auto Reserve Stock for Sales Order

This commit is contained in:
s-aga-r 2023-10-18 12:38:42 +05:30
parent 36a996d704
commit 2b4fa98941
2 changed files with 18 additions and 23 deletions

View File

@ -87,17 +87,13 @@ frappe.ui.form.on("Sales Order", {
frm.events.get_items_from_internal_purchase_order(frm); frm.events.get_items_from_internal_purchase_order(frm);
} }
if (frm.is_new()) { if (frm.doc.docstatus === 0) {
frappe.db.get_single_value("Stock Settings", "enable_stock_reservation").then((value) => { frappe.db.get_single_value("Stock Settings", "enable_stock_reservation").then((value) => {
if (value) { if (!value) {
frappe.db.get_single_value("Stock Settings", "auto_reserve_stock_for_sales_order").then((value) => { // If `Stock Reservation` is disabled in Stock Settings, set Reserve Stock to 0 and make the field read-only and hidden.
// If `Reserve Stock on Sales Order Submission` is enabled in Stock Settings, set Reserve Stock to 1 else 0.
frm.set_value("reserve_stock", value ? 1 : 0);
})
} else {
// If `Stock Reservation` is disabled in Stock Settings, set Reserve Stock to 0 and read only.
frm.set_value("reserve_stock", 0); frm.set_value("reserve_stock", 0);
frm.set_df_property("reserve_stock", "read_only", 1); frm.set_df_property("reserve_stock", "read_only", 1);
frm.set_df_property("reserve_stock", "hidden", 1);
} }
}) })
} }

View File

@ -38,8 +38,8 @@
"stock_reservation_tab", "stock_reservation_tab",
"enable_stock_reservation", "enable_stock_reservation",
"column_break_rx3e", "column_break_rx3e",
"auto_reserve_stock_for_sales_order",
"allow_partial_reservation", "allow_partial_reservation",
"auto_reserve_stock_for_sales_order_on_purchase",
"serial_and_batch_reservation_section", "serial_and_batch_reservation_section",
"auto_reserve_serial_and_batch", "auto_reserve_serial_and_batch",
"serial_and_batch_item_settings_tab", "serial_and_batch_item_settings_tab",
@ -65,8 +65,7 @@
"stock_frozen_upto_days", "stock_frozen_upto_days",
"column_break_26", "column_break_26",
"role_allowed_to_create_edit_back_dated_transactions", "role_allowed_to_create_edit_back_dated_transactions",
"stock_auth_role", "stock_auth_role"
"section_break_plhx"
], ],
"fields": [ "fields": [
{ {
@ -356,7 +355,7 @@
{ {
"default": "1", "default": "1",
"depends_on": "eval: doc.enable_stock_reservation", "depends_on": "eval: doc.enable_stock_reservation",
"description": "If enabled, <b>Partial Stock Reservation Entries</b> can be created. For example, If you have a Sales Order of 100 units and the Available Stock is 90 units then a Stock Reservation Entry will be created for 90 units. ", "description": "Partial stock can be reserved. For example, If you have a Sales Order of 100 units and the Available Stock is 90 units then a Stock Reservation Entry will be created for 90 units. ",
"fieldname": "allow_partial_reservation", "fieldname": "allow_partial_reservation",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Allow Partial Reservation" "label": "Allow Partial Reservation"
@ -383,7 +382,7 @@
{ {
"default": "1", "default": "1",
"depends_on": "eval: doc.enable_stock_reservation", "depends_on": "eval: doc.enable_stock_reservation",
"description": "If enabled, Serial and Batch Nos will be auto-reserved based on <b>Pick Serial / Batch Based On</b>", "description": "Serial and Batch Nos will be auto-reserved based on <b>Pick Serial / Batch Based On</b>",
"fieldname": "auto_reserve_serial_and_batch", "fieldname": "auto_reserve_serial_and_batch",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Auto Reserve Serial and Batch Nos" "label": "Auto Reserve Serial and Batch Nos"
@ -393,14 +392,6 @@
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Serial and Batch Reservation" "label": "Serial and Batch Reservation"
}, },
{
"default": "0",
"depends_on": "eval: doc.enable_stock_reservation",
"description": "If enabled, <b>Stock Reservation Entries</b> will be created on submission of <b>Sales Order</b>",
"fieldname": "auto_reserve_stock_for_sales_order",
"fieldtype": "Check",
"label": "Auto Reserve Stock for Sales Order"
},
{ {
"fieldname": "conversion_factor_section", "fieldname": "conversion_factor_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
@ -421,6 +412,14 @@
"fieldname": "allow_to_edit_stock_uom_qty_for_purchase", "fieldname": "allow_to_edit_stock_uom_qty_for_purchase",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Allow to Edit Stock UOM Qty for Purchase Documents" "label": "Allow to Edit Stock UOM Qty for Purchase Documents"
},
{
"default": "0",
"depends_on": "eval: doc.enable_stock_reservation",
"description": "Stock will be reserved on submission of <b>Purchase Receipt</b> created against Material Receipt for Sales Order.",
"fieldname": "auto_reserve_stock_for_sales_order_on_purchase",
"fieldtype": "Check",
"label": "Auto Reserve Stock for Sales Order on Purchase"
} }
], ],
"icon": "icon-cog", "icon": "icon-cog",
@ -428,7 +427,7 @@
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"issingle": 1, "issingle": 1,
"links": [], "links": [],
"modified": "2023-10-01 14:22:36.136111", "modified": "2023-10-18 12:35:30.068799",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Stock Settings", "name": "Stock Settings",