Skip to content

Commit

Permalink
fix: validation trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitwaghchaure committed Oct 30, 2024
1 parent f12ec7a commit c879c46
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions erpnext/manufacturing/doctype/bom/bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,10 @@ def validate_operations(self):
if not d.batch_size or d.batch_size <= 0:
d.batch_size = 1

if not d.workstation and not d.workstation_type:
msg = f"Row {d.idx}: Workstation or Workstation Type is mandatory for an operation {d.operation}"
frappe.throw(_(msg))

def get_tree_representation(self) -> BOMTree:
"""Get a complete tree representation preserving order of child items."""
return BOMTree(self.name)
Expand Down
10 changes: 8 additions & 2 deletions erpnext/manufacturing/doctype/work_order/work_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,16 @@ def reset_use_multi_level_bom(self):
self.get_items_and_operations_from_bom()

def validate_workstation_type(self):
if not self.docstatus.is_submitted():
return

for row in self.operations:
if not row.workstation and not row.workstation_type:
msg = f"Row {row.idx}: Workstation or Workstation Type is mandatory for an operation {row.operation}"
frappe.throw(_(msg))
frappe.throw(
_("Row {0}: Workstation or Workstation Type is mandatory for an operation {1}").format(
row.idx, row.operation
)
)

def validate_sales_order(self):
if self.sales_order:
Expand Down

0 comments on commit c879c46

Please sign in to comment.