fix: get_serial_nos_for_fg() missing 1 required positional argument: 'args'
This commit is contained in:
parent
2175784142
commit
410a58b3de
@ -1154,6 +1154,36 @@ class TestWorkOrder(FrappeTestCase):
|
|||||||
except frappe.MandatoryError:
|
except frappe.MandatoryError:
|
||||||
self.fail("Batch generation causing failing in Work Order")
|
self.fail("Batch generation causing failing in Work Order")
|
||||||
|
|
||||||
|
@change_settings("Manufacturing Settings", {"make_serial_no_batch_from_work_order": 1})
|
||||||
|
def test_auto_serial_no_creation(self):
|
||||||
|
from erpnext.manufacturing.doctype.bom.test_bom import create_nested_bom
|
||||||
|
|
||||||
|
fg_item = frappe.generate_hash(length=20)
|
||||||
|
child_item = frappe.generate_hash(length=20)
|
||||||
|
|
||||||
|
bom_tree = {fg_item: {child_item: {}}}
|
||||||
|
|
||||||
|
create_nested_bom(bom_tree, prefix="")
|
||||||
|
|
||||||
|
item = frappe.get_doc("Item", fg_item)
|
||||||
|
item.has_serial_no = 1
|
||||||
|
item.serial_no_series = f"{item.name}.#####"
|
||||||
|
item.save()
|
||||||
|
|
||||||
|
try:
|
||||||
|
wo_order = make_wo_order_test_record(item=fg_item, qty=2, skip_transfer=True)
|
||||||
|
serial_nos = wo_order.serial_no
|
||||||
|
stock_entry = frappe.get_doc(make_stock_entry(wo_order.name, "Manufacture", 10))
|
||||||
|
stock_entry.set_work_order_details()
|
||||||
|
stock_entry.set_serial_no_batch_for_finished_good()
|
||||||
|
for row in stock_entry.items:
|
||||||
|
if row.item_code == fg_item:
|
||||||
|
self.assertTrue(row.serial_no)
|
||||||
|
self.assertEqual(sorted(get_serial_nos(row.serial_no)), sorted(get_serial_nos(serial_nos)))
|
||||||
|
|
||||||
|
except frappe.MandatoryError:
|
||||||
|
self.fail("Batch generation causing failing in Work Order")
|
||||||
|
|
||||||
@change_settings(
|
@change_settings(
|
||||||
"Manufacturing Settings",
|
"Manufacturing Settings",
|
||||||
{"backflush_raw_materials_based_on": "Material Transferred for Manufacture"},
|
{"backflush_raw_materials_based_on": "Material Transferred for Manufacture"},
|
||||||
|
@ -2236,16 +2236,16 @@ class StockEntry(StockController):
|
|||||||
d.qty -= process_loss_dict[d.item_code][1]
|
d.qty -= process_loss_dict[d.item_code][1]
|
||||||
|
|
||||||
def set_serial_no_batch_for_finished_good(self):
|
def set_serial_no_batch_for_finished_good(self):
|
||||||
serial_nos = ""
|
serial_nos = []
|
||||||
if self.pro_doc.serial_no:
|
if self.pro_doc.serial_no:
|
||||||
serial_nos = self.get_serial_nos_for_fg()
|
serial_nos = self.get_serial_nos_for_fg() or []
|
||||||
|
|
||||||
for row in self.items:
|
for row in self.items:
|
||||||
if row.is_finished_item and row.item_code == self.pro_doc.production_item:
|
if row.is_finished_item and row.item_code == self.pro_doc.production_item:
|
||||||
if serial_nos:
|
if serial_nos:
|
||||||
row.serial_no = "\n".join(serial_nos[0 : cint(row.qty)])
|
row.serial_no = "\n".join(serial_nos[0 : cint(row.qty)])
|
||||||
|
|
||||||
def get_serial_nos_for_fg(self, args):
|
def get_serial_nos_for_fg(self):
|
||||||
fields = [
|
fields = [
|
||||||
"`tabStock Entry`.`name`",
|
"`tabStock Entry`.`name`",
|
||||||
"`tabStock Entry Detail`.`qty`",
|
"`tabStock Entry Detail`.`qty`",
|
||||||
@ -2261,8 +2261,6 @@ class StockEntry(StockController):
|
|||||||
]
|
]
|
||||||
|
|
||||||
stock_entries = frappe.get_all("Stock Entry", fields=fields, filters=filters)
|
stock_entries = frappe.get_all("Stock Entry", fields=fields, filters=filters)
|
||||||
|
|
||||||
if self.pro_doc.serial_no:
|
|
||||||
return self.get_available_serial_nos(stock_entries)
|
return self.get_available_serial_nos(stock_entries)
|
||||||
|
|
||||||
def get_available_serial_nos(self, stock_entries):
|
def get_available_serial_nos(self, stock_entries):
|
||||||
|
Loading…
Reference in New Issue
Block a user