diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py index 20f8a4ab553..41716b015a3 100644 --- a/erpnext/manufacturing/doctype/work_order/work_order.py +++ b/erpnext/manufacturing/doctype/work_order/work_order.py @@ -351,15 +351,16 @@ class WorkOrder(Document): def update_status(self, status=None): """Update status of work order if unknown""" - if status != "Stopped" and status != "Closed": - status = self.get_status(status) + if self.status != "Closed": + if status not in ["Stopped", "Closed"]: + status = self.get_status(status) - if status != self.status: - self.db_set("status", status) + if status != self.status: + self.db_set("status", status) - self.update_required_items() + self.update_required_items() - return status + return status or self.status def get_status(self, status=None): """Return the status based on stock entries against this work order"""