Skip to content

Commit

Permalink
fix: add validation for PO in Stock Entry (#31974)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-aga-r authored Aug 25, 2022
1 parent 9e43c9c commit 8566832
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions erpnext/stock/doctype/stock_entry/stock_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def validate(self):
self.validate_warehouse()
self.validate_work_order()
self.validate_bom()
self.validate_purchase_order()

if self.purpose in ("Manufacture", "Repack"):
self.mark_finished_and_scrap_items()
Expand Down Expand Up @@ -946,6 +947,19 @@ def validate_bom(self):
item_code = d.original_item or d.item_code
validate_bom_no(item_code, d.bom_no)

def validate_purchase_order(self):
if self.purpose == "Send to Subcontractor" and self.get("purchase_order"):
is_old_subcontracting_flow = frappe.db.get_value(
"Purchase Order", self.purchase_order, "is_old_subcontracting_flow"
)

if not is_old_subcontracting_flow:
frappe.throw(
_("Please select Subcontracting Order instead of Purchase Order {0}").format(
self.purchase_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 8566832

Please sign in to comment.