diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index b92e920dd76..6029a073961 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -341,21 +341,6 @@ class BOM(WebsiteGenerator): ).format(item.idx, get_link_to_form("Item", item.item_code)) ) -<<<<<<< HEAD - if item.qty is None: - frappe.throw( -<<<<<<< HEAD - _("Row #{0}: Quantity should be greater than 0 for {1} Item {2}").format( - item.idx, item.type, get_link_to_form("Item", item.item_code) -======= - _("Row #{0}: Quantity is required for {1} Item {2}").format( - item.idx, item.secondary_item_type, get_link_to_form("Item", item.item_code) ->>>>>>> 6771daf6a1 (fix(bom): allow zero qty for secondary items (Co-Product, By-Product, Scrap, Additional Finished Good)) - ) - ) - -======= ->>>>>>> c1bef53f92 (refactor(bom): drop redundant secondary item qty None check) if item.process_loss_per >= 100: frappe.throw( _("Row #{0}: Process Loss Percentage should be less than 100% for {1} Item {2}").format( diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index ea62554e642..55463364a3c 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -1379,18 +1379,13 @@ class StockEntry(StockController, SubcontractingInwardController): for d in self.get("items"): if d.s_warehouse or d.set_basic_rate_manually: continue -<<<<<<< HEAD -======= # Zero-qty secondary items carry no inventory value; skip rate calculation - if d.secondary_item_type and flt(d.transfer_qty) == 0: + if d.type and flt(d.transfer_qty) == 0: d.basic_rate = 0.0 d.basic_amount = 0.0 continue - self._set_incoming_item_rate(d, outgoing_items_cost, raise_error_if_no_rate, zero_valuation_items) ->>>>>>> de3df6bcef (fix(manufacture): preserve user-entered rate for secondary items with zero cost allocation) - if d.allow_zero_valuation_rate and d.basic_rate and self.purpose != "Receive from Customer": d.basic_rate = 0.0 items.append(d.item_code) @@ -1408,24 +1403,14 @@ class StockEntry(StockController, SubcontractingInwardController): cost_allocation_per = frappe.get_value( "BOM Secondary Item", d.bom_secondary_item, "cost_allocation_per" ) - d.basic_rate = (outgoing_items_cost * (cost_allocation_per / 100)) / d.transfer_qty + # Only recalculate when cost is actually allocated; otherwise preserve the + # user-entered rate (or fall through to get_valuation_rate below) + if cost_allocation_per and flt(d.transfer_qty): + d.basic_rate = (outgoing_items_cost * (cost_allocation_per / 100)) / d.transfer_qty -<<<<<<< HEAD if not d.basic_rate and not d.allow_zero_valuation_rate: if self.is_new(): raise_error_if_no_rate = False -======= - if self.bom_no: - d.basic_rate *= frappe.get_value("BOM", self.bom_no, "cost_allocation_per") / 100 - elif d.secondary_item_type and d.bom_secondary_item: - cost_allocation_per = frappe.get_value( - "BOM Secondary Item", d.bom_secondary_item, "cost_allocation_per" - ) - # Only recalculate when cost is actually allocated; otherwise preserve the - # user-entered rate (or fall through to get_valuation_rate below) - if cost_allocation_per and flt(d.transfer_qty): - d.basic_rate = (outgoing_items_cost * (cost_allocation_per / 100)) / d.transfer_qty ->>>>>>> de3df6bcef (fix(manufacture): preserve user-entered rate for secondary items with zero cost allocation) d.basic_rate = get_valuation_rate( d.item_code,