Skip to content

Commit

Permalink
fix(ux): no need to select rows to unreserve the stock
Browse files Browse the repository at this point in the history
  • Loading branch information
s-aga-r committed Nov 22, 2023
1 parent 73586fd commit 2a41da9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 5 additions & 5 deletions erpnext/selling/doctype/sales_order/sales_order.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ frappe.ui.form.on("Sales Order", {
cancel_stock_reservation_entries(frm) {
const dialog = new frappe.ui.Dialog({
title: __("Stock Unreservation"),
size: "large",
size: "extra-large",
fields: [
{
fieldname: "sr_entries",
Expand All @@ -316,9 +316,9 @@ frappe.ui.form.on("Sales Order", {
data: [],
fields: [
{
fieldname: "name",
fieldname: "sre",
fieldtype: "Link",
label: __("SRE"),
label: __("Stock Reservation Entry"),
options: "Stock Reservation Entry",
reqd: 1,
read_only: 1,
Expand Down Expand Up @@ -362,7 +362,7 @@ frappe.ui.form.on("Sales Order", {
doc: frm.doc,
method: "cancel_stock_reservation_entries",
args: {
sre_list: data.sr_entries,
sre_list: data.sr_entries.map(item => item.sre),
},
freeze: true,
freeze_message: __('Unreserving Stock...'),
Expand All @@ -388,7 +388,7 @@ frappe.ui.form.on("Sales Order", {
r.message.forEach(sre => {
if (flt(sre.reserved_qty) > flt(sre.delivered_qty)) {
dialog.fields_dict.sr_entries.df.data.push({
'name': sre.name,
'sre': sre.name,
'item_code': sre.item_code,
'warehouse': sre.warehouse,
'qty': (flt(sre.reserved_qty) - flt(sre.delivered_qty))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1053,12 +1053,14 @@ def cancel_stock_reservation_entries(
from_voucher_type: Literal["Pick List", "Purchase Receipt"] = None,
from_voucher_no: str = None,
from_voucher_detail_no: str = None,
sre_list: list[dict] = None,
sre_list: list = None,
notify: bool = True,
) -> None:
"""Cancel Stock Reservation Entries."""

if not sre_list:
sre_list = {}

if voucher_type and voucher_no:
sre_list = get_stock_reservation_entries_for_voucher(
voucher_type, voucher_no, voucher_detail_no, fields=["name"]
Expand All @@ -1082,9 +1084,11 @@ def cancel_stock_reservation_entries(

sre_list = query.run(as_dict=True)

sre_list = [d.name for d in sre_list]

if sre_list:
for sre in sre_list:
frappe.get_doc("Stock Reservation Entry", sre["name"]).cancel()
frappe.get_doc("Stock Reservation Entry", sre).cancel()

if notify:
msg = _("Stock Reservation Entries Cancelled")
Expand Down

0 comments on commit 2a41da9

Please sign in to comment.