mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-14 15:11:52 +00:00
fix: name every conflicting voucher in the reserved batch error
This commit is contained in:
@@ -1360,14 +1360,14 @@ class StockController(AccountsController):
|
|||||||
own_vouchers = {item.get(field) for item in items for field in reference_fields if item.get(field)}
|
own_vouchers = {item.get(field) for item in items for field in reference_fields if item.get(field)}
|
||||||
|
|
||||||
outstanding_qty = defaultdict(float)
|
outstanding_qty = defaultdict(float)
|
||||||
reservations = {}
|
reservations = defaultdict(list)
|
||||||
for row in self.get_reserved_batches(batches):
|
for row in self.get_reserved_batches(batches):
|
||||||
if row.voucher_no in own_vouchers:
|
if row.voucher_no in own_vouchers:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
key = (row.batch_no, row.warehouse)
|
key = (row.batch_no, row.warehouse)
|
||||||
outstanding_qty[key] += flt(row.qty) - flt(row.delivered_qty)
|
outstanding_qty[key] += flt(row.qty) - flt(row.delivered_qty)
|
||||||
reservations.setdefault(key, row)
|
reservations[key].append(row)
|
||||||
|
|
||||||
for (batch_no, warehouse), reserved_qty in outstanding_qty.items():
|
for (batch_no, warehouse), reserved_qty in outstanding_qty.items():
|
||||||
if reserved_qty <= 0:
|
if reserved_qty <= 0:
|
||||||
@@ -1384,14 +1384,18 @@ class StockController(AccountsController):
|
|||||||
if flt(batch_qty, 6) >= flt(reserved_qty, 6):
|
if flt(batch_qty, 6) >= flt(reserved_qty, 6):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
row = reservations[(batch_no, warehouse)]
|
vouchers = ", ".join(
|
||||||
|
f"{frappe.bold(voucher_type)} {frappe.bold(voucher_no)}"
|
||||||
|
for voucher_type, voucher_no in dict.fromkeys(
|
||||||
|
(row.voucher_type, row.voucher_no) for row in reservations[(batch_no, warehouse)]
|
||||||
|
)
|
||||||
|
)
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
_(
|
_(
|
||||||
"The batch {0} is reserved for {1} {2} in the warehouse {3} and the remaining quantity is not enough to cover the reservation. So, cannot proceed with the {4} {5}."
|
"The batch {0} is reserved for {1} in the warehouse {2} and the remaining quantity is not enough to cover the reservations. So, cannot proceed with the {3} {4}."
|
||||||
).format(
|
).format(
|
||||||
frappe.bold(batch_no),
|
frappe.bold(batch_no),
|
||||||
frappe.bold(row.voucher_type),
|
vouchers,
|
||||||
frappe.bold(row.voucher_no),
|
|
||||||
frappe.bold(warehouse),
|
frappe.bold(warehouse),
|
||||||
frappe.bold(self.doctype),
|
frappe.bold(self.doctype),
|
||||||
frappe.bold(self.name),
|
frappe.bold(self.name),
|
||||||
|
|||||||
Reference in New Issue
Block a user