Skip to content

Commit

Permalink
fix: validate Subcontracting Order in Stock Entry
Browse files Browse the repository at this point in the history
(cherry picked from commit 9a3dcb9)
  • Loading branch information
s-aga-r authored and mergify[bot] committed Sep 9, 2022
1 parent 844f120 commit d3cc9d4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions erpnext/stock/doctype/stock_entry/stock_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def validate(self):
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()
Expand Down Expand Up @@ -959,6 +960,20 @@ def validate_purchase_order(self):
)
)

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
Expand Down

0 comments on commit d3cc9d4

Please sign in to comment.