fix: add validation for PO in Stock Entry (#31974)
This commit is contained in:
parent
9e43c9cff3
commit
8566832dd5
@ -116,6 +116,7 @@ class StockEntry(StockController):
|
|||||||
self.validate_warehouse()
|
self.validate_warehouse()
|
||||||
self.validate_work_order()
|
self.validate_work_order()
|
||||||
self.validate_bom()
|
self.validate_bom()
|
||||||
|
self.validate_purchase_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()
|
||||||
@ -946,6 +947,19 @@ class StockEntry(StockController):
|
|||||||
item_code = d.original_item or d.item_code
|
item_code = d.original_item or d.item_code
|
||||||
validate_bom_no(item_code, d.bom_no)
|
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):
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user