fix: validation trigger (#43926)

This commit is contained in:
rohitwaghchaure
2024-10-31 22:55:01 +05:30
committed by GitHub
parent 01bb1612da
commit ba9fb4effc
2 changed files with 15 additions and 2 deletions

View File

@@ -1018,6 +1018,13 @@ class BOM(WebsiteGenerator):
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)

View File

@@ -191,10 +191,16 @@ class WorkOrder(Document):
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: