From bc2fa037300ace55f0e021b43fc195d29479e654 Mon Sep 17 00:00:00 2001 From: Shllokkk Date: Thu, 10 Sep 2026 18:53:39 +0530 Subject: [PATCH] fix: coerce cost_allocation_per to float in BOM cost allocation --- erpnext/manufacturing/doctype/bom/bom.py | 7 ++++--- erpnext/manufacturing/doctype/bom/services/costing.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index c916e2c7b32..022afa93129 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -487,9 +487,10 @@ class BOM(WebsiteGenerator): doc.set_status(save=True) def set_fg_cost_allocation(self): + self.cost_allocation_per = flt(self.cost_allocation_per) total_secondary_items_per = 0 for item in self.secondary_items: - total_secondary_items_per += item.cost_allocation_per + total_secondary_items_per += flt(item.cost_allocation_per) if self.cost_allocation_per == 100 and total_secondary_items_per: self.cost_allocation_per -= total_secondary_items_per @@ -497,9 +498,9 @@ class BOM(WebsiteGenerator): self.cost_allocation = self.raw_material_cost * (self.cost_allocation_per / 100) def validate_total_cost_allocation(self): - total_cost_allocation_per = self.cost_allocation_per + total_cost_allocation_per = flt(self.cost_allocation_per) for item in self.secondary_items: - total_cost_allocation_per += item.cost_allocation_per + total_cost_allocation_per += flt(item.cost_allocation_per) if total_cost_allocation_per != 100: frappe.throw(_("Cost allocation between finished goods and secondary items should equal 100%")) diff --git a/erpnext/manufacturing/doctype/bom/services/costing.py b/erpnext/manufacturing/doctype/bom/services/costing.py index b72d1b8909d..d96577cf0a3 100644 --- a/erpnext/manufacturing/doctype/bom/services/costing.py +++ b/erpnext/manufacturing/doctype/bom/services/costing.py @@ -268,7 +268,7 @@ class BOMCostingService: for d in self.doc.get("secondary_items"): if not d.is_legacy: - d.cost = flt(self.doc.raw_material_cost * (d.cost_allocation_per / 100), precision) + d.cost = flt(self.doc.raw_material_cost * (flt(d.cost_allocation_per) / 100), precision) d.base_cost = flt(d.cost * self.doc.conversion_rate, precision) total_sm_cost += d.cost