From 30909a9b79442adf4fdc09461388c5fdf2897033 Mon Sep 17 00:00:00 2001 From: Sagar Sharma Date: Fri, 9 Sep 2022 13:45:31 +0530 Subject: [PATCH 1/2] fix: status filter for Subcontracting Order in Stock Entry --- erpnext/stock/doctype/stock_entry/stock_entry.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 1bbe570807..a952a93ac7 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -815,7 +815,8 @@ erpnext.stock.StockEntry = class StockEntry extends erpnext.stock.StockControlle return { "filters": { "docstatus": 1, - "company": me.frm.doc.company + "company": me.frm.doc.company, + "status": ["not in", ["Completed", "Closed"]] } }; }); From 9a3dcb9ad163e9023df5b6417683a49b517f87b7 Mon Sep 17 00:00:00 2001 From: Sagar Sharma Date: Fri, 9 Sep 2022 13:46:50 +0530 Subject: [PATCH 2/2] fix: validate Subcontracting Order in Stock Entry --- erpnext/stock/doctype/stock_entry/stock_entry.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index d70952282d..5344eb8d94 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -117,6 +117,7 @@ class StockEntry(StockController): self.validate_work_order() self.validate_bom() self.validate_purchase_order() + self.validate_subcontracting_order() if self.purpose in ("Manufacture", "Repack"): self.mark_finished_and_scrap_items() @@ -960,6 +961,20 @@ class StockEntry(StockController): ) ) + def validate_subcontracting_order(self): + if self.get("subcontracting_order") and self.purpose in [ + "Send to Subcontractor", + "Material Transfer", + ]: + sco_status = frappe.db.get_value("Subcontracting Order", self.subcontracting_order, "status") + + if sco_status == "Closed": + frappe.throw( + _("Cannot create Stock Entry against a closed Subcontracting Order {0}.").format( + self.subcontracting_order + ) + ) + def mark_finished_and_scrap_items(self): if any([d.item_code for d in self.items if (d.is_finished_item and d.t_warehouse)]): return