fix: re-validate PO while updating items
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 081abe1..843103d 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -3055,11 +3055,20 @@
parent.update_ordered_qty()
parent.update_ordered_and_reserved_qty()
parent.update_receiving_percentage()
- if parent.is_old_subcontracting_flow:
- if should_update_supplied_items(parent):
- parent.update_reserved_qty_for_subcontract()
- parent.create_raw_materials_supplied()
- parent.save()
+
+ if parent.is_subcontracted:
+ if parent.is_old_subcontracting_flow:
+ if should_update_supplied_items(parent):
+ parent.update_reserved_qty_for_subcontract()
+ parent.create_raw_materials_supplied()
+ parent.save()
+ else:
+ if not parent.can_update_items():
+ frappe.throw(
+ _(
+ "Items cannot be updated as Subcontracting Order is created against the Purchase Order {0}."
+ ).format(frappe.bold(parent.name))
+ )
else: # Sales Order
parent.validate_warehouse()
parent.update_reserved_qty()