From b2f10eb240184a1306e59ae4cc15ddf98feb9d77 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Thu, 18 Apr 2024 14:24:51 +0530 Subject: [PATCH] fix: validation for fraction number in Work Order --- .../doctype/work_order/work_order.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py index 1cb10a48d6..786352ff15 100644 --- a/erpnext/manufacturing/doctype/work_order/work_order.py +++ b/erpnext/manufacturing/doctype/work_order/work_order.py @@ -890,6 +890,21 @@ class WorkOrder(Document): if self.qty <= 0: frappe.throw(_("Quantity to Manufacture must be greater than 0.")) + if ( + self.stock_uom + and frappe.get_cached_value("UOM", self.stock_uom, "must_be_whole_number") + and abs(cint(self.qty) - flt(self.qty, self.precision("qty"))) > 0.0000001 + ): + frappe.throw( + _( + "Qty To Manufacture ({0}) cannot be a fraction for the UOM {2}. To allow this, disable '{1}' in the UOM {2}." + ).format( + flt(self.qty, self.precision("qty")), + frappe.bold(_("Must be Whole Number")), + frappe.bold(self.stock_uom), + ), + ) + if ( self.production_plan and self.production_plan_item -- GitLab