Skip to content

Commit

Permalink
fix(ux): Sales Order Stock Reservation Dialog (backport #40707) (#40980)
Browse files Browse the repository at this point in the history
fix(ux): Sales Order Stock Reservation Dialog

(cherry picked from commit 5daf19d)

Co-authored-by: s-aga-r <sagarsharma.s312@gmail.com>
  • Loading branch information
mergify[bot] and s-aga-r committed Apr 12, 2024
1 parent 3762259 commit 14a1a18
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions erpnext/selling/doctype/sales_order/sales_order.js
Expand Up @@ -288,6 +288,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 @@ -356,7 +357,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 @@ -373,9 +374,11 @@ frappe.ui.form.on("Sales Order", {
frm.reload_doc();
},
});
}

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

Expand All @@ -390,6 +393,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 @@ -414,6 +418,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 @@ -457,7 +462,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 @@ -473,9 +478,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 14a1a18

Please sign in to comment.