diff --git a/erpnext/accounts/doctype/sales_invoice/test_records.json b/erpnext/accounts/doctype/sales_invoice/test_records.json index a022225435..732c4465a8 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_records.json +++ b/erpnext/accounts/doctype/sales_invoice/test_records.json @@ -21,6 +21,8 @@ "parentfield": "items", "qty": 1.0, "rate": 500.0, + "uom": "_Test UOM", + "conversion_factor": 1, "stock_uom": "_Test UOM" } ], @@ -91,6 +93,8 @@ "parentfield": "items", "price_list_rate": 500.0, "qty": 1.0, + "uom": "_Test UOM", + "conversion_factor": 1, "stock_uom": "_Test UOM" } ], @@ -143,6 +147,8 @@ "price_list_rate": 50, "qty": 10, "rate": 50, + "uom": "_Test UOM", + "conversion_factor": 1, "stock_uom": "_Test UOM" }, { @@ -155,6 +161,8 @@ "parentfield": "items", "price_list_rate": 150, "qty": 5, + "uom": "_Test UOM", + "conversion_factor": 1, "rate": 150, "stock_uom": "_Test UOM" } @@ -265,6 +273,8 @@ "parentfield": "items", "price_list_rate": 62.5, "qty": 10, + "uom": "_Test UOM", + "conversion_factor": 1, "stock_uom": "_Test UOM" }, @@ -278,6 +288,8 @@ "parentfield": "items", "price_list_rate": 190.66, "qty": 5, + "uom": "_Test UOM", + "conversion_factor": 1, "stock_uom": "_Test UOM" } ], diff --git a/erpnext/selling/doctype/quotation/test_records.json b/erpnext/selling/doctype/quotation/test_records.json index b41fcc9697..8a37dbb7d7 100644 --- a/erpnext/selling/doctype/quotation/test_records.json +++ b/erpnext/selling/doctype/quotation/test_records.json @@ -23,6 +23,7 @@ "parentfield": "items", "qty": 10.0, "rate": 100.0, + "uom": "_Test UOM", "stock_uom": "_Test UOM", "conversion_factor": 1.0 } diff --git a/erpnext/selling/doctype/sales_order/test_records.json b/erpnext/selling/doctype/sales_order/test_records.json index 7b13fb7740..12e953a1b6 100644 --- a/erpnext/selling/doctype/sales_order/test_records.json +++ b/erpnext/selling/doctype/sales_order/test_records.json @@ -28,7 +28,8 @@ "rate": 100.0, "warehouse": "_Test Warehouse - _TC", "stock_uom": "_Test UOM", - "conversion_factor": 1.0 + "conversion_factor": 1.0, + "uom": "_Test UOM" } ], "selling_price_list": "_Test Price List", diff --git a/erpnext/stock/doctype/delivery_note/test_records.json b/erpnext/stock/doctype/delivery_note/test_records.json index 9c11286b0b..c76bab2cce 100644 --- a/erpnext/stock/doctype/delivery_note/test_records.json +++ b/erpnext/stock/doctype/delivery_note/test_records.json @@ -18,6 +18,8 @@ "parentfield": "items", "qty": 1.0, "rate": 100.0, + "uom": "_Test UOM", + "conversion_factor": 1, "stock_uom": "_Test UOM", "warehouse": "_Test Warehouse - _TC" } diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 7854ac45f1..be20a810c2 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -510,7 +510,7 @@ def get_valuation_rate(item_code, warehouse=None): ["valuation_rate"], as_dict=True) or {"valuation_rate": 0} elif not item.is_stock_item: - valuation_rate =frappe.db.sql("""select sum(base_net_amount) / sum(stock_qty) + valuation_rate =frappe.db.sql("""select sum(base_net_amount) / sum(qty*conversion_factor) from `tabPurchase Invoice Item` where item_code = %s and docstatus=1""", item_code)