Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ux): Sales Order Stock Reservation Dialog (backport #40707) #40980

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -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