mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-26 21:35:19 +00:00
Co-authored-by: Sudharsanan Ashok <135326972+Sudharsanan11@users.noreply.github.com> Co-authored-by: Mihir Kandoi <kandoimihir@gmail.com>
This commit is contained in:
@@ -1179,12 +1179,15 @@ def get_item_and_warehouses(item_code, warehouse):
|
|||||||
from frappe.utils.nestedset import get_descendants_of
|
from frappe.utils.nestedset import get_descendants_of
|
||||||
|
|
||||||
items = []
|
items = []
|
||||||
|
stock_uom = frappe.get_cached_value("Item", item_code, "stock_uom")
|
||||||
if frappe.get_cached_value("Warehouse", warehouse, "is_group"):
|
if frappe.get_cached_value("Warehouse", warehouse, "is_group"):
|
||||||
childrens = get_descendants_of("Warehouse", warehouse, ignore_permissions=True, order_by="lft")
|
childrens = get_descendants_of("Warehouse", warehouse, ignore_permissions=True, order_by="lft")
|
||||||
for ch_warehouse in childrens:
|
for ch_warehouse in childrens:
|
||||||
items.append(frappe._dict({"item_code": item_code, "warehouse": ch_warehouse}))
|
items.append(
|
||||||
|
frappe._dict({"item_code": item_code, "warehouse": ch_warehouse, "stock_uom": stock_uom})
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
items = [frappe._dict({"item_code": item_code, "warehouse": warehouse})]
|
items = [frappe._dict({"item_code": item_code, "warehouse": warehouse, "stock_uom": stock_uom})]
|
||||||
|
|
||||||
return items
|
return items
|
||||||
|
|
||||||
@@ -1194,7 +1197,8 @@ def get_items_for_stock_reco(warehouse, company):
|
|||||||
items = frappe.db.sql(
|
items = frappe.db.sql(
|
||||||
f"""
|
f"""
|
||||||
select
|
select
|
||||||
i.name as item_code, i.item_name, bin.warehouse as warehouse, i.has_serial_no, i.has_batch_no
|
i.name as item_code, i.item_name, bin.warehouse as warehouse, i.has_serial_no, i.has_batch_no,
|
||||||
|
i.stock_uom
|
||||||
from
|
from
|
||||||
`tabBin` bin, `tabItem` i
|
`tabBin` bin, `tabItem` i
|
||||||
where
|
where
|
||||||
@@ -1212,7 +1216,8 @@ def get_items_for_stock_reco(warehouse, company):
|
|||||||
items += frappe.db.sql(
|
items += frappe.db.sql(
|
||||||
"""
|
"""
|
||||||
select
|
select
|
||||||
i.name as item_code, i.item_name, id.default_warehouse as warehouse, i.has_serial_no, i.has_batch_no
|
i.name as item_code, i.item_name, id.default_warehouse as warehouse, i.has_serial_no,
|
||||||
|
i.has_batch_no, i.stock_uom
|
||||||
from
|
from
|
||||||
`tabItem` i, `tabItem Default` id
|
`tabItem` i, `tabItem Default` id
|
||||||
where
|
where
|
||||||
@@ -1258,6 +1263,7 @@ def get_item_data(row, qty, valuation_rate, serial_no=None):
|
|||||||
"current_serial_no": serial_no,
|
"current_serial_no": serial_no,
|
||||||
"serial_no": serial_no,
|
"serial_no": serial_no,
|
||||||
"batch_no": row.get("batch_no"),
|
"batch_no": row.get("batch_no"),
|
||||||
|
"stock_uom": row.get("stock_uom"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1285,6 +1291,7 @@ def get_itemwise_batch(warehouse, posting_date, company, item_code=None):
|
|||||||
"valuation_rate": row[9],
|
"valuation_rate": row[9],
|
||||||
"item_name": row[1],
|
"item_name": row[1],
|
||||||
"batch_no": row[4],
|
"batch_no": row[4],
|
||||||
|
"stock_uom": row[11],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ class TestStockReconciliation(ERPNextTestSuite, StockTestMixin):
|
|||||||
"_Test Stock Reco Item",
|
"_Test Stock Reco Item",
|
||||||
is_stock_item=1,
|
is_stock_item=1,
|
||||||
valuation_rate=100,
|
valuation_rate=100,
|
||||||
|
stock_uom="_Test UOM",
|
||||||
warehouse="_Test Warehouse Ledger 1 - _TC",
|
warehouse="_Test Warehouse Ledger 1 - _TC",
|
||||||
opening_stock=100,
|
opening_stock=100,
|
||||||
)
|
)
|
||||||
@@ -148,8 +149,8 @@ class TestStockReconciliation(ERPNextTestSuite, StockTestMixin):
|
|||||||
items = get_items("_Test Warehouse Group 1 - _TC", nowdate(), nowtime(), "_Test Company")
|
items = get_items("_Test Warehouse Group 1 - _TC", nowdate(), nowtime(), "_Test Company")
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
["_Test Stock Reco Item", "_Test Warehouse Ledger 1 - _TC", 100],
|
["_Test Stock Reco Item", "_Test Warehouse Ledger 1 - _TC", 100, "_Test UOM"],
|
||||||
[items[0]["item_code"], items[0]["warehouse"], items[0]["qty"]],
|
[items[0]["item_code"], items[0]["warehouse"], items[0]["qty"], items[0]["stock_uom"]],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_stock_reco_for_serialized_item(self):
|
def test_stock_reco_for_serialized_item(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user