From a689830bff72e85c940e4fc3a897edaeaa2b2c38 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sun, 3 Nov 2024 04:20:01 +0530 Subject: [PATCH] fix: validation trigger (backport #43926) (#43943) fix: validation trigger (#43926) (cherry picked from commit ba9fb4effc32f7e5454b8a0bab664195b6cb2108) Co-authored-by: rohitwaghchaure --- erpnext/manufacturing/doctype/bom/bom.py | 7 +++++++ erpnext/manufacturing/doctype/work_order/work_order.py | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index 009320c7a18..843528de706 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -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) diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py index d13cd27a095..1ebcde75366 100644 --- a/erpnext/manufacturing/doctype/work_order/work_order.py +++ b/erpnext/manufacturing/doctype/work_order/work_order.py @@ -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: