fix: ignore qty msg if From Voucher is set

This commit is contained in:
s-aga-r
2023-10-23 16:26:00 +05:30
parent 4f363f5bf3
commit a432290a82

View File

@@ -833,6 +833,7 @@ def create_stock_reservation_entries_for_so_items(
# Skip if Non-Stock Item. # Skip if Non-Stock Item.
if not is_stock_item: if not is_stock_item:
if not from_voucher_type:
frappe.msgprint( frappe.msgprint(
_("Row #{0}: Stock cannot be reserved for a non-stock Item {1}").format( _("Row #{0}: Stock cannot be reserved for a non-stock Item {1}").format(
item.idx, frappe.bold(item.item_code) item.idx, frappe.bold(item.item_code)
@@ -840,6 +841,7 @@ def create_stock_reservation_entries_for_so_items(
title=_("Stock Reservation"), title=_("Stock Reservation"),
indicator="yellow", indicator="yellow",
) )
item.db_set("reserve_stock", 0) item.db_set("reserve_stock", 0)
continue continue
@@ -858,6 +860,7 @@ def create_stock_reservation_entries_for_so_items(
# Stock is already reserved for the item, notify the user and skip the item. # Stock is already reserved for the item, notify the user and skip the item.
if unreserved_qty <= 0: if unreserved_qty <= 0:
if not from_voucher_type:
frappe.msgprint( frappe.msgprint(
_("Row #{0}: Stock is already reserved for the Item {1}.").format( _("Row #{0}: Stock is already reserved for the Item {1}.").format(
item.idx, frappe.bold(item.item_code) item.idx, frappe.bold(item.item_code)
@@ -865,6 +868,7 @@ def create_stock_reservation_entries_for_so_items(
title=_("Stock Reservation"), title=_("Stock Reservation"),
indicator="yellow", indicator="yellow",
) )
continue continue
available_qty_to_reserve = get_available_qty_to_reserve(item.item_code, item.warehouse) available_qty_to_reserve = get_available_qty_to_reserve(item.item_code, item.warehouse)
@@ -872,7 +876,7 @@ def create_stock_reservation_entries_for_so_items(
# No stock available to reserve, notify the user and skip the item. # No stock available to reserve, notify the user and skip the item.
if available_qty_to_reserve <= 0: if available_qty_to_reserve <= 0:
frappe.msgprint( frappe.msgprint(
_("Row #{0}: No available stock to reserve for the Item {1} in Warehouse {2}.").format( _("Row #{0}: Stock not available to reserve for the Item {1} in Warehouse {2}.").format(
item.idx, frappe.bold(item.item_code), frappe.bold(item.warehouse) item.idx, frappe.bold(item.item_code), frappe.bold(item.warehouse)
), ),
title=_("Stock Reservation"), title=_("Stock Reservation"),
@@ -898,7 +902,9 @@ def create_stock_reservation_entries_for_so_items(
# Partial Reservation # Partial Reservation
if qty_to_be_reserved < unreserved_qty: if qty_to_be_reserved < unreserved_qty:
if not item.get("qty_to_reserve") or qty_to_be_reserved < flt(item.get("qty_to_reserve")): if not from_voucher_type and (
not item.get("qty_to_reserve") or qty_to_be_reserved < flt(item.get("qty_to_reserve"))
):
msg = _("Row #{0}: Only {1} available to reserve for the Item {2}").format( msg = _("Row #{0}: Only {1} available to reserve for the Item {2}").format(
item.idx, item.idx,
frappe.bold(str(qty_to_be_reserved / item.conversion_factor) + " " + item.uom), frappe.bold(str(qty_to_be_reserved / item.conversion_factor) + " " + item.uom),