fix: remove redundant method
(cherry picked from commit 57d5a027fb929803ffd62463da3e5b4611b17ff4)
diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.js b/erpnext/assets/doctype/asset_repair/asset_repair.js
index 18454fe..1e4c4e0 100644
--- a/erpnext/assets/doctype/asset_repair/asset_repair.js
+++ b/erpnext/assets/doctype/asset_repair/asset_repair.js
@@ -69,18 +69,23 @@
frappe.ui.form.on('Asset Repair Consumed Item', {
item_code: function(frm, cdt, cdn) {
- var row = locals[cdt][cdn];
+ var item = locals[cdt][cdn];
- frappe.call ({
- method: "erpnext.assets.doctype.asset_repair.asset_repair.get_valuation_rate",
+ let item_args = {
+ 'item_code': item.item_code,
+ 'warehouse': frm.doc.warehouse,
+ 'qty': item.consumed_quantity,
+ 'serial_no': item.serial_no,
+ 'company': frm.doc.company
+ }
+
+ frappe.call({
+ method: 'erpnext.stock.utils.get_incoming_rate',
args: {
- "item_code": row.item_code,
- "warehouse": frm.doc.warehouse
+ args: item_args
},
callback: function(r) {
- if(r.message) {
- frappe.model.set_value(cdt, cdn, 'valuation_rate', r.message);
- }
+ frappe.model.set_value(cdt, cdn, 'valuation_rate', r.message);
}
});
},
diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.py b/erpnext/assets/doctype/asset_repair/asset_repair.py
index d5e3d3c..36848e9 100644
--- a/erpnext/assets/doctype/asset_repair/asset_repair.py
+++ b/erpnext/assets/doctype/asset_repair/asset_repair.py
@@ -256,36 +256,3 @@
def get_downtime(failure_date, completion_date):
downtime = time_diff_in_hours(completion_date, failure_date)
return round(downtime, 2)
-
-@frappe.whitelist()
-def get_valuation_rate(item_code, warehouse):
- last_valuation_rate = frappe.get_all(
- "Stock Ledger Entry",
- filters = {
- "item_code": item_code,
- "warehouse": warehouse,
- "valuation_rate": [">=", 0],
- "docstatus": ["<", 2]
- },
- pluck = "valuation_rate",
- order_by = "posting_date desc, posting_time desc, name desc"
- )
-
- if last_valuation_rate:
- return last_valuation_rate[0]
- else:
- valuation_rate = frappe.db.get_value("Item", item_code, "valuation_rate")
-
- if not valuation_rate:
- # try Item Standard rate
- valuation_rate = frappe.db.get_value("Item", item_code, "standard_rate")
-
- if not valuation_rate:
- # try in price list
- valuation_rate = frappe.db.get_value(
- "Item Price",
- dict(item_code=item_code, buying=1),
- "price_list_rate"
- )
-
- return valuation_rate