Skip to content

Commit

Permalink
fix(ux): Sales Order Stock Reservation Dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
s-aga-r committed Mar 27, 2024
1 parent dfde490 commit 5daf19d
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions erpnext/selling/doctype/sales_order/sales_order.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ frappe.ui.form.on("Sales Order", {
label: __("Items to Reserve"),
allow_bulk_edit: false,
cannot_add_rows: true,
cannot_delete_rows: true,
data: [],
fields: [
{
Expand Down Expand Up @@ -346,7 +347,7 @@ frappe.ui.form.on("Sales Order", {
],
primary_action_label: __("Reserve Stock"),
primary_action: () => {
var data = { items: dialog.fields_dict.items.grid.data };
var data = { items: dialog.fields_dict.items.grid.get_selected_children() };

if (data.items && data.items.length > 0) {
frappe.call({
Expand All @@ -363,9 +364,11 @@ frappe.ui.form.on("Sales Order", {
frm.reload_doc();
},
});
}

dialog.hide();
dialog.hide();
} else {
frappe.msgprint(__("Please select items to reserve."));
}
},
});

Expand All @@ -380,6 +383,7 @@ frappe.ui.form.on("Sales Order", {

if (unreserved_qty > 0) {
dialog.fields_dict.items.df.data.push({
__checked: 1,
sales_order_item: item.name,
item_code: item.item_code,
warehouse: item.warehouse,
Expand All @@ -404,6 +408,7 @@ frappe.ui.form.on("Sales Order", {
label: __("Reserved Stock"),
allow_bulk_edit: false,
cannot_add_rows: true,
cannot_delete_rows: true,
in_place_edit: true,
data: [],
fields: [
Expand Down Expand Up @@ -447,7 +452,7 @@ frappe.ui.form.on("Sales Order", {
],
primary_action_label: __("Unreserve Stock"),
primary_action: () => {
var data = { sr_entries: dialog.fields_dict.sr_entries.grid.data };
var data = { sr_entries: dialog.fields_dict.sr_entries.grid.get_selected_children() };

if (data.sr_entries && data.sr_entries.length > 0) {
frappe.call({
Expand All @@ -463,9 +468,11 @@ frappe.ui.form.on("Sales Order", {
frm.reload_doc();
},
});
}

dialog.hide();
dialog.hide();
} else {
frappe.msgprint(__("Please select items to unreserve."));
}
},
});

Expand Down

0 comments on commit 5daf19d

Please sign in to comment.