Skip to content

Commit

Permalink
Merge pull request #30377 from marination/stock-entry-items-idx
Browse files Browse the repository at this point in the history
fix: Dont set `idx` while adding WO items to Stock Entry
  • Loading branch information
marination authored Mar 30, 2022
2 parents 87dc9c6 + b5ad626 commit 7e719a1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
4 changes: 2 additions & 2 deletions erpnext/manufacturing/doctype/bom/bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ def get_bom_items_as_dict(
query = query.format(
table="BOM Scrap Item",
where_conditions="",
select_columns=", bom_item.idx, item.description, is_process_loss",
select_columns=", item.description, is_process_loss",
is_stock_item=is_stock_item,
qty_field="stock_qty",
)
Expand All @@ -1038,7 +1038,7 @@ def get_bom_items_as_dict(
is_stock_item=is_stock_item,
qty_field="stock_qty" if fetch_qty_in_stock_uom else "qty",
select_columns=""", bom_item.uom, bom_item.conversion_factor, bom_item.source_warehouse,
bom_item.idx, bom_item.operation, bom_item.include_item_in_manufacturing, bom_item.sourced_by_supplier,
bom_item.operation, bom_item.include_item_in_manufacturing, bom_item.sourced_by_supplier,
bom_item.description, bom_item.base_rate as rate """,
)
items = frappe.db.sql(query, {"qty": qty, "bom": bom, "company": company}, as_dict=True)
Expand Down
30 changes: 30 additions & 0 deletions erpnext/manufacturing/doctype/work_order/test_work_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,36 @@ def test_auto_batch_creation(self):
except frappe.MandatoryError:
self.fail("Batch generation causing failing in Work Order")

@change_settings(
"Manufacturing Settings",
{"backflush_raw_materials_based_on": "Material Transferred for Manufacture"},
)
def test_manufacture_entry_mapped_idx_with_exploded_bom(self):
"""Test if WO containing BOM with partial exploded items and scrap items, maps idx correctly."""
test_stock_entry.make_stock_entry(
item_code="_Test Item",
target="_Test Warehouse - _TC",
basic_rate=5000.0,
qty=2,
)
test_stock_entry.make_stock_entry(
item_code="_Test Item Home Desktop 100",
target="_Test Warehouse - _TC",
basic_rate=1000.0,
qty=2,
)

wo_order = make_wo_order_test_record(
qty=1,
use_multi_level_bom=1,
skip_transfer=1,
)

ste_manu = frappe.get_doc(make_stock_entry(wo_order.name, "Manufacture", 1))

for index, row in enumerate(ste_manu.get("items"), start=1):
self.assertEqual(index, row.idx)


def update_job_card(job_card, jc_qty=None):
employee = frappe.db.get_value("Employee", {"status": "Active"}, "name")
Expand Down
2 changes: 0 additions & 2 deletions erpnext/stock/doctype/stock_entry/stock_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,6 @@ def set_scrap_items(self):
if self.purpose != "Send to Subcontractor" and self.purpose in ["Manufacture", "Repack"]:
scrap_item_dict = self.get_bom_scrap_material(self.fg_completed_qty)
for item in scrap_item_dict.values():
item.idx = ""
if self.pro_doc and self.pro_doc.scrap_warehouse:
item["to_warehouse"] = self.pro_doc.scrap_warehouse

Expand Down Expand Up @@ -1902,7 +1901,6 @@ def add_to_stock_entry_detail(self, item_dict, bom_no=None):
se_child.is_process_loss = item_row.get("is_process_loss", 0)

for field in [
"idx",
"po_detail",
"original_item",
"expense_account",
Expand Down

0 comments on commit 7e719a1

Please sign in to comment.