mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 16:04:46 +00:00
Merge pull request #32147 from frappe/mergify/bp/version-14-hotfix/pr-32145
fix: validate Subcontracting Order Status in Stock Entry (backport #32145)
This commit is contained in:
@@ -815,7 +815,8 @@ erpnext.stock.StockEntry = class StockEntry extends erpnext.stock.StockControlle
|
|||||||
return {
|
return {
|
||||||
"filters": {
|
"filters": {
|
||||||
"docstatus": 1,
|
"docstatus": 1,
|
||||||
"company": me.frm.doc.company
|
"company": me.frm.doc.company,
|
||||||
|
"status": ["not in", ["Completed", "Closed"]]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ class StockEntry(StockController):
|
|||||||
self.validate_work_order()
|
self.validate_work_order()
|
||||||
self.validate_bom()
|
self.validate_bom()
|
||||||
self.validate_purchase_order()
|
self.validate_purchase_order()
|
||||||
|
self.validate_subcontracting_order()
|
||||||
|
|
||||||
if self.purpose in ("Manufacture", "Repack"):
|
if self.purpose in ("Manufacture", "Repack"):
|
||||||
self.mark_finished_and_scrap_items()
|
self.mark_finished_and_scrap_items()
|
||||||
@@ -959,6 +960,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):
|
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)]):
|
if any([d.item_code for d in self.items if (d.is_finished_item and d.t_warehouse)]):
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user