fix: validation trigger (backport #43926) (#43943)

fix: validation trigger (#43926)

(cherry picked from commit ba9fb4effc)

Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
mergify[bot]
2024-11-03 04:20:01 +05:30
committed by GitHub
parent 4a749cec72
commit a689830bff
2 changed files with 15 additions and 2 deletions

View File

@@ -968,6 +968,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

@@ -173,10 +173,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: