From b9b1717e96f2dbb78ff9816d41270ed5aae626bb Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Tue, 22 Aug 2023 16:53:54 +0530 Subject: [PATCH] fix: re-validate PO while updating items --- erpnext/controllers/accounts_controller.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 081abe12104..843103da9bf 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -3055,11 +3055,20 @@ def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name, chil 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()