fix: supplier warehouse in PR
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index 4db8ccb..97843f7 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -323,22 +323,19 @@
d.margin_rate_or_amount = 0.0
def validate_for_subcontracting(self):
- if self.is_subcontracted:
+ if self.is_subcontracted and self.get("is_old_subcontracting_flow"):
if self.doctype in ["Purchase Receipt", "Purchase Invoice"] and not self.supplier_warehouse:
frappe.throw(_("Supplier Warehouse mandatory for sub-contracted {0}").format(self.doctype))
- if self.get("is_old_subcontracting_flow"):
- for item in self.get("items"):
- if item in self.sub_contracted_items and not item.bom:
- frappe.throw(_("Please select BOM in BOM field for Item {0}").format(item.item_code))
-
- if self.doctype != "Purchase Order":
- return
-
- for row in self.get("supplied_items"):
- if not row.reserve_warehouse:
- msg = f"Reserved Warehouse is mandatory for the Item {frappe.bold(row.rm_item_code)} in Raw Materials supplied"
- frappe.throw(_(msg))
+ for item in self.get("items"):
+ if item in self.sub_contracted_items and not item.bom:
+ frappe.throw(_("Please select BOM in BOM field for Item {0}").format(item.item_code))
+ if self.doctype != "Purchase Order":
+ return
+ for row in self.get("supplied_items"):
+ if not row.reserve_warehouse:
+ msg = f"Reserved Warehouse is mandatory for the Item {frappe.bold(row.rm_item_code)} in Raw Materials supplied"
+ frappe.throw(_(msg))
else:
for item in self.get("items"):
if item.get("bom"):
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
index e6fcb78..312c166 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
@@ -198,7 +198,7 @@
cur_frm.add_custom_button(__('Reopen'), this.reopen_purchase_receipt, __("Status"))
}
- this.frm.toggle_reqd("supplier_warehouse", this.frm.doc.is_subcontracted);
+ this.frm.toggle_reqd("supplier_warehouse", this.frm.doc.is_old_subcontracting_flow);
}
make_purchase_invoice() {
@@ -300,7 +300,7 @@
erpnext.buying.get_default_bom(frm);
}
- frm.toggle_reqd("supplier_warehouse", frm.doc.is_subcontracted);
+ frm.toggle_reqd("supplier_warehouse", frm.doc.is_old_subcontracting_flow);
});
frappe.ui.form.on('Purchase Receipt Item', {