Skip to content

Commit

Permalink
fix: validation trigger (#43926)
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitwaghchaure authored Oct 31, 2024
1 parent 01bb161 commit ba9fb4e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
7 changes: 7 additions & 0 deletions erpnext/manufacturing/doctype/bom/bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,13 @@ 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:
frappe.throw(
_(
"Row {0}: Workstation or Workstation Type is mandatory for an operation {1}"
).format(d.idx, d.operation)
)

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 ba9fb4e

Please sign in to comment.