Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add validation for PO in Stock Entry #31974

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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