Skip to content

Commit

Permalink
fix(ux): hide Unreserve button once reserved stock is delivered
Browse files Browse the repository at this point in the history
  • Loading branch information
s-aga-r committed Aug 26, 2023
1 parent 89853d7 commit 53a4bb0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions erpnext/selling/doctype/sales_order/sales_order.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,17 @@ frappe.ui.form.on("Sales Order", {
}
}

// Stock Reservation > Unreserve/Reserved Stock button will be only visible if the SO has reserved stock.
// Stock Reservation > Unreserve button will be only visible if the SO has un-delivered reserved stock.
if (frm.doc.__onload && frm.doc.__onload.has_reserved_stock) {
frm.add_custom_button(__('Unreserve'), () => frm.events.cancel_stock_reservation_entries(frm), __('Stock Reservation'));
frm.add_custom_button(__('Reserved Stock'), () => frm.events.show_reserved_stock(frm), __('Stock Reservation'));
}

frm.doc.items.forEach(item => {
if (flt(item.stock_reserved_qty) > 0) {
frm.add_custom_button(__('Reserved Stock'), () => frm.events.show_reserved_stock(frm), __('Stock Reservation'));
return;
}
});
}

if (frm.doc.docstatus === 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ def has_reserved_stock(voucher_type: str, voucher_no: str, voucher_detail_no: st
"""Returns True if there is any Stock Reservation Entry for the given voucher."""

if get_stock_reservation_entries_for_voucher(
voucher_type, voucher_no, voucher_detail_no, fields=["name"]
voucher_type, voucher_no, voucher_detail_no, fields=["name"], ignore_status=True
):
return True

Expand Down

0 comments on commit 53a4bb0

Please sign in to comment.