fix(buying): allow purchase returns against a closed purchase order (#58126)

This commit is contained in:
Pandiyan P
2026-08-13 17:55:41 +05:30
committed by GitHub
parent 1e583725a1
commit fd728dacca
4 changed files with 47 additions and 9 deletions

View File

@@ -929,6 +929,13 @@ class BuyingController(SubcontractingController):
item.serial_and_batch_bundle, warehouse, type_of_transaction=type_of_transaction
)
def check_purchase_order_on_hold_or_close(self, ref_fieldname, exclude_if_field=None):
if self.get("is_return"):
return
self.check_for_on_hold_or_closed_status(
"Purchase Order", ref_fieldname, exclude_if_field=exclude_if_field
)
def update_ordered_and_reserved_qty(self):
po_map = {}
for d in self.get("items"):
@@ -942,7 +949,7 @@ class BuyingController(SubcontractingController):
if po and po_item_rows:
po_obj = frappe.get_lazy_doc("Purchase Order", po)
if po_obj.status in ["Closed", "Cancelled"]:
if po_obj.status == "Cancelled" or (po_obj.status == "Closed" and not self.get("is_return")):
frappe.throw(
_("{doctype} {name} is cancelled or closed.").format(
doctype=frappe.bold(_("Purchase Order")),