fix: supplier warehouse in PR

This commit is contained in:
Sagar Sharma 2022-07-01 16:51:19 +05:30
parent b86710bb9a
commit fd162f9b14
2 changed files with 12 additions and 15 deletions

View File

@ -323,22 +323,19 @@ class BuyingController(SubcontractingController):
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"):

View File

@ -198,7 +198,7 @@ erpnext.stock.PurchaseReceiptController = class PurchaseReceiptController extend
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 @@ frappe.ui.form.on("Purchase Receipt", "is_subcontracted", function(frm) {
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', {