From 741e6a7e5229880a1f098a73d89a6f2fa8b6fbbd Mon Sep 17 00:00:00 2001 From: "coderabbitai[bot]" <136622811+coderabbitai[bot]@users.noreply.github.com> Date: Sat, 6 Dec 2025 05:39:35 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Add=20docstrings=20to=20`wo-flt-?= =?UTF-8?q?issue`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Docstrings generation was requested by @rtdany10. * https://github.com/frappe/erpnext/pull/50952#issuecomment-3619564968 The following files were modified: * `erpnext/manufacturing/doctype/work_order/work_order.py` --- .../doctype/work_order/work_order.py | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py index 71bd94ad73a..53ad5b53285 100644 --- a/erpnext/manufacturing/doctype/work_order/work_order.py +++ b/erpnext/manufacturing/doctype/work_order/work_order.py @@ -1319,6 +1319,17 @@ class WorkOrder(Document): return holidays[holiday_list] def update_operation_status(self): + """ + Update each operation's status based on its completed quantity and process loss relative to the work order quantity and overproduction allowance. + + For every operation, sets status to: + - "Pending" when completed + process loss is zero. + - "Work in Progress" when completed + process loss is greater than zero but less than the work order quantity. + - "Completed" when completed + process loss is equal to or within the allowed overproduction amount for the work order. + + Raises: + frappe.ValidationError: If an operation's completed quantity plus process loss exceeds the maximum allowed quantity for the work order (work order qty plus configured overproduction percentage). + """ allowance_percentage = flt( frappe.db.get_single_value("Manufacturing Settings", "overproduction_percentage_for_work_order") ) @@ -1326,14 +1337,14 @@ class WorkOrder(Document): for d in self.get("operations"): precision = d.precision("completed_qty") - qty = flt(d.completed_qty, precision) + flt(d.process_loss_qty, precision) + qty = flt(flt(d.completed_qty, precision) + flt(d.process_loss_qty, precision), precision) if not qty: d.status = "Pending" - elif flt(qty) < flt(self.qty): + elif qty < flt(self.qty, precision): d.status = "Work in Progress" - elif flt(qty) == flt(self.qty): + elif qty == flt(self.qty, precision): d.status = "Completed" - elif flt(qty) <= max_allowed_qty_for_wo: + elif qty <= flt(max_allowed_qty_for_wo, precision): d.status = "Completed" else: frappe.throw(_("Completed Qty cannot be greater than 'Qty to Manufacture'")) @@ -2755,4 +2766,4 @@ def get_row_wise_serial_batch(work_order, purpose=None): @frappe.request_cache def get_hour_rate(workstation): - return frappe.get_cached_value("Workstation", workstation, "hour_rate") or 0.0 + return frappe.get_cached_value("Workstation", workstation, "hour_rate") or 0.0 \ No newline at end of file