Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create bom, create wo & added manufacturing scrap without consumption… #1142

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions erpnext/manufacturing/doctype/work_order/test_work_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -2528,6 +2528,61 @@ def test_manufacture_with_work_order_batch_serial_without_consum_TC_SCK_173(self
serial_cnt = frappe.db.count('Serial and Batch Bundle',{'voucher_no':ste_doc.name,'has_serial_no':1, 'has_batch_no':1})
self.assertEqual(serial_cnt, 1)

def test_manfu_wo_scrap_without_consum_TC_SCK_174(self):
frappe.db.set_single_value(
"Manufacturing Settings",
"backflush_raw_materials_based_on",
"Material Transferred for Manufacture",
)

item = make_item(
"Test FG Item To Test Return Case",
{
"is_stock_item": 1,
},
)

item_raw = make_item("Test raw material")
item_code = item.name
bom_doc = make_bom(
item=item_code,
source_warehouse="Stores - _TC",
raw_materials=[item_raw],
rm_qty=10,
do_not_submit=True
)
item_scrap = make_item("Test scrap material1")
frappe.db.set_value('Item',item_scrap.item_code,'valuation_rate',20)
bom_doc.append("scrap_items", {"item_code": item_scrap.item_code, "qty": 1})
bom_doc.submit()

# Create a work order
wo_doc = make_wo_order_test_record(production_item=item_code, qty=10)
wo_doc.save()
self.assertEqual(wo_doc.bom_no, bom_doc.name)

self.assertEqual(wo_doc.status, "Not Started")
# Transfer material for manufacture
ste_doc = frappe.get_doc(make_stock_entry(wo_doc.name, "Material Transfer for Manufacture", 10))
for row in ste_doc.items:
test_stock_entry.make_stock_entry(
item_code=row.item_code, target="Stores - _TC", qty=row.qty, basic_rate=100
)

ste_doc.save()
ste_doc.submit()
ste_doc.load_from_db()

# Create a stock entry to manufacture the item
ste_doc = frappe.get_doc(make_stock_entry(wo_doc.name, "Manufacture", 10))
for row in ste_doc.items:
row.use_serial_batch_fields = 1

ste_doc.save()
ste_doc.submit()
wo_doc.load_from_db()
self.assertEqual(wo_doc.status, "Completed")

def make_operation(**kwargs):
kwargs = frappe._dict(kwargs)

Expand Down
Loading