fix(manufacturing): allow to edit batch size while creating a work order (#55058)

This commit is contained in:
Sudharsanan Ashok
2026-05-27 11:27:17 +05:30
committed by GitHub
parent 8bb611dfee
commit 3ad67021d6
5 changed files with 17 additions and 8 deletions

View File

@@ -1,5 +1,6 @@
{ {
"actions": [], "actions": [],
"allow_bulk_edit": 1,
"creation": "2013-02-22 01:27:49", "creation": "2013-02-22 01:27:49",
"doctype": "DocType", "doctype": "DocType",
"document_type": "Setup", "document_type": "Setup",
@@ -139,11 +140,13 @@
"label": "Image" "label": "Image"
}, },
{ {
"default": "1",
"fetch_from": "operation.batch_size", "fetch_from": "operation.batch_size",
"fetch_if_empty": 1, "fetch_if_empty": 1,
"fieldname": "batch_size", "fieldname": "batch_size",
"fieldtype": "Int", "fieldtype": "Float",
"label": "Batch Size" "label": "Batch Size",
"non_negative": 1
}, },
{ {
"depends_on": "eval:doc.parenttype == \"Routing\" || !parent.routing", "depends_on": "eval:doc.parenttype == \"Routing\" || !parent.routing",
@@ -304,7 +307,7 @@
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"istable": 1, "istable": 1,
"links": [], "links": [],
"modified": "2026-04-01 17:09:48.771834", "modified": "2026-05-25 17:15:42.044630",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Manufacturing", "module": "Manufacturing",
"name": "BOM Operation", "name": "BOM Operation",

View File

@@ -18,7 +18,7 @@ class BOMOperation(Document):
base_cost_per_unit: DF.Float base_cost_per_unit: DF.Float
base_hour_rate: DF.Currency base_hour_rate: DF.Currency
base_operating_cost: DF.Currency base_operating_cost: DF.Currency
batch_size: DF.Int batch_size: DF.Float
bom_no: DF.Link | None bom_no: DF.Link | None
cost_per_unit: DF.Float cost_per_unit: DF.Float
description: DF.TextEditor | None description: DF.TextEditor | None

View File

@@ -4225,6 +4225,7 @@ class TestWorkOrder(ERPNextTestSuite):
"operations", "operations",
{ {
"operation": fg_operation.name, "operation": fg_operation.name,
"batch_size": fg_operation.batch_size,
"time_in_mins": 60, "time_in_mins": 60,
"workstation": workstation.name, "workstation": workstation.name,
}, },
@@ -4233,6 +4234,7 @@ class TestWorkOrder(ERPNextTestSuite):
fg_bom.items[0].bom_no = subassembly_bom.name fg_bom.items[0].bom_no = subassembly_bom.name
fg_bom.save() fg_bom.save()
fg_bom.submit() fg_bom.submit()
self.assertEqual(fg_bom.operations[0].batch_size, 25)
wo_order = make_wo_order_test_record( wo_order = make_wo_order_test_record(
item=fg_item.name, item=fg_item.name,

View File

@@ -202,7 +202,7 @@ class WorkOrder(Document):
self.calculate_operating_cost() self.calculate_operating_cost()
self.validate_qty() self.validate_qty()
self.validate_transfer_against() self.validate_transfer_against()
self.validate_operation_time() self.validate_operations()
self.status = self.get_status() self.status = self.get_status()
self.validate_workstation_type() self.validate_workstation_type()
self.reset_use_multi_level_bom() self.reset_use_multi_level_bom()
@@ -1499,8 +1499,11 @@ class WorkOrder(Document):
title=_("Missing value"), title=_("Missing value"),
) )
def validate_operation_time(self): def validate_operations(self):
for d in self.operations: for d in self.operations:
if not d.batch_size or d.batch_size <= 0:
d.batch_size = 1
if d.time_in_mins <= 0: if d.time_in_mins <= 0:
frappe.throw(_("Operation Time must be greater than 0 for Operation {0}").format(d.operation)) frappe.throw(_("Operation Time must be greater than 0 for Operation {0}").format(d.operation))

View File

@@ -196,10 +196,11 @@
"read_only": 1 "read_only": 1
}, },
{ {
"default": "1",
"fieldname": "batch_size", "fieldname": "batch_size",
"fieldtype": "Float", "fieldtype": "Float",
"label": "Batch Size", "label": "Batch Size",
"read_only": 1 "non_negative": 1
}, },
{ {
"fieldname": "sequence_id", "fieldname": "sequence_id",
@@ -316,7 +317,7 @@
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"istable": 1, "istable": 1,
"links": [], "links": [],
"modified": "2026-05-20 13:01:21.827200", "modified": "2026-05-25 17:15:12.038470",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Manufacturing", "module": "Manufacturing",
"name": "Work Order Operation", "name": "Work Order Operation",