Skip to content

Commit

Permalink
Merge branch 'develop' into validate-project-dates
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra authored Dec 5, 2022
2 parents 31db0e7 + d0478ec commit a2abc87
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
3 changes: 2 additions & 1 deletion erpnext/accounts/doctype/sales_invoice/sales_invoice.json
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@
"fieldtype": "Table",
"hide_days": 1,
"hide_seconds": 1,
"label": "Sales Taxes and Charges",
"oldfieldname": "other_charges",
"oldfieldtype": "Table",
"options": "Sales Taxes and Charges"
Expand Down Expand Up @@ -2133,7 +2134,7 @@
"link_fieldname": "consolidated_invoice"
}
],
"modified": "2022-11-17 17:17:10.883487",
"modified": "2022-12-05 16:18:14.532114",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice",
Expand Down
24 changes: 23 additions & 1 deletion erpnext/manufacturing/doctype/work_order/test_work_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,10 @@ def test_batch_size_for_fg_item(self):
bom.submit()
bom_name = bom.name

ste1 = test_stock_entry.make_stock_entry(
item_code=rm1, target="_Test Warehouse - _TC", qty=32, basic_rate=5000.0
)

work_order = make_wo_order_test_record(
item=fg_item, skip_transfer=True, planned_start_date=now(), qty=1
)
Expand All @@ -659,11 +663,29 @@ def test_batch_size_for_fg_item(self):
work_order.insert()
work_order.submit()
self.assertEqual(work_order.has_batch_no, 1)
ste1 = frappe.get_doc(make_stock_entry(work_order.name, "Manufacture", 30))
batches = frappe.get_all("Batch", filters={"reference_name": work_order.name})
self.assertEqual(len(batches), 3)
batches = [batch.name for batch in batches]

ste1 = frappe.get_doc(make_stock_entry(work_order.name, "Manufacture", 10))
for row in ste1.get("items"):
if row.is_finished_item:
self.assertEqual(row.item_code, fg_item)
self.assertEqual(row.qty, 10)
self.assertTrue(row.batch_no in batches)
batches.remove(row.batch_no)

ste1.submit()

remaining_batches = []
ste1 = frappe.get_doc(make_stock_entry(work_order.name, "Manufacture", 20))
for row in ste1.get("items"):
if row.is_finished_item:
self.assertEqual(row.item_code, fg_item)
self.assertEqual(row.qty, 10)
remaining_batches.append(row.batch_no)

self.assertEqual(sorted(remaining_batches), sorted(batches))

frappe.db.set_value("Manufacturing Settings", None, "make_serial_no_batch_from_work_order", 0)

Expand Down
13 changes: 7 additions & 6 deletions erpnext/stock/doctype/stock_entry/stock_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1545,6 +1545,7 @@ def set_batchwise_finished_goods(self, args, item):
"reference_name": self.pro_doc.name,
"reference_doctype": self.pro_doc.doctype,
"qty_to_produce": (">", 0),
"batch_qty": ("=", 0),
}

fields = ["qty_to_produce as qty", "produced_qty", "name"]
Expand Down Expand Up @@ -2238,14 +2239,14 @@ def update_items_for_process_loss(self):
d.qty -= process_loss_dict[d.item_code][1]

def set_serial_no_batch_for_finished_good(self):
args = {}
serial_nos = ""
if self.pro_doc.serial_no:
self.get_serial_nos_for_fg(args)
serial_nos = self.get_serial_nos_for_fg()

for row in self.items:
if row.is_finished_item and row.item_code == self.pro_doc.production_item:
if args.get("serial_no"):
row.serial_no = "\n".join(args["serial_no"][0 : cint(row.qty)])
if serial_nos:
row.serial_no = "\n".join(serial_nos[0 : cint(row.qty)])

def get_serial_nos_for_fg(self, args):
fields = [
Expand All @@ -2258,14 +2259,14 @@ def get_serial_nos_for_fg(self, args):
filters = [
["Stock Entry", "work_order", "=", self.work_order],
["Stock Entry", "purpose", "=", "Manufacture"],
["Stock Entry", "docstatus", "=", 1],
["Stock Entry", "docstatus", "<", 2],
["Stock Entry Detail", "item_code", "=", self.pro_doc.production_item],
]

stock_entries = frappe.get_all("Stock Entry", fields=fields, filters=filters)

if self.pro_doc.serial_no:
args["serial_no"] = self.get_available_serial_nos(stock_entries)
return self.get_available_serial_nos(stock_entries)

def get_available_serial_nos(self, stock_entries):
used_serial_nos = []
Expand Down

0 comments on commit a2abc87

Please sign in to comment.