fix: Update item detail for items without reference
diff --git a/erpnext/stock/doctype/material_request/material_request.py b/erpnext/stock/doctype/material_request/material_request.py
index 7040d83..9cad3f0 100644
--- a/erpnext/stock/doctype/material_request/material_request.py
+++ b/erpnext/stock/doctype/material_request/material_request.py
@@ -521,7 +521,6 @@
'name': 'material_request_item',
'qty': 'stock_qty'
},
- # 'condition': lambda doc: abs(doc.transferred_qty) < abs(doc.required_qty)
},
}, target_doc)
diff --git a/erpnext/stock/doctype/pick_list/pick_list.js b/erpnext/stock/doctype/pick_list/pick_list.js
index 0a78fae..0d00024 100644
--- a/erpnext/stock/doctype/pick_list/pick_list.js
+++ b/erpnext/stock/doctype/pick_list/pick_list.js
@@ -27,7 +27,7 @@
};
});
},
- get_item_locations(frm) {
+ get_item_locations: (frm) => {
frm.call('set_item_locations');
},
refresh: (frm) => {
@@ -84,18 +84,22 @@
source_name: frm.doc.material_request
});
},
+ parent_warehouse: (frm) => {
+ frm.clear_table('locations');
+ frm.refresh_field('locations');
+ },
purpose: (frm) => {
frm.clear_table('items');
frm.clear_table('locations');
frm.trigger('add_get_items_button');
},
- create_delivery_note(frm) {
+ create_delivery_note: (frm) => {
frappe.model.open_mapped_doc({
method: 'erpnext.stock.doctype.pick_list.pick_list.create_delivery_note',
frm: frm
});
},
- create_stock_entry(frm) {
+ create_stock_entry: (frm) => {
frappe.xcall('erpnext.stock.doctype.pick_list.pick_list.create_stock_entry', {
'pick_list': frm.doc,
}).then(stock_entry => {
@@ -103,7 +107,7 @@
frappe.set_route("Form", 'Stock Entry', stock_entry.name);
});
},
- add_get_items_button(frm) {
+ add_get_items_button: (frm) => {
let purpose = frm.doc.purpose;
if (purpose != 'Delivery against Sales Order' || frm.doc.docstatus !== 0) return;
let get_query_filters = {
@@ -130,4 +134,40 @@
});
});
}
-});
\ No newline at end of file
+});
+
+frappe.ui.form.on('Pick List Reference Item', {
+ item_code: (frm, cdt, cdn) => {
+ let row = frappe.get_doc(cdt, cdn);
+ if (row.item_code) {
+ get_item_details(row.item_code).then(data => {
+ frappe.model.set_value(cdt, cdn, 'uom', data.stock_uom);
+ frappe.model.set_value(cdt, cdn, 'stock_uom', data.stock_uom);
+ frappe.model.set_value(cdt, cdn, 'conversion_factor', 1);
+ });
+ }
+ },
+ uom: (frm, cdt, cdn) => {
+ let row = frappe.get_doc(cdt, cdn);
+ if (row.uom) {
+ get_item_details(row.item_code, row.uom).then(data => {
+ frappe.model.set_value(cdt, cdn, 'conversion_factor', data.conversion_factor);
+ });
+ }
+ },
+ qty: (frm, cdt, cdn) => {
+ let row = frappe.get_doc(cdt, cdn);
+ frappe.model.set_value(cdt, cdn, 'stock_qty', row.qty * row.conversion_factor);
+ },
+ conversion_factor: (frm, cdt, cdn) => {
+ let row = frappe.get_doc(cdt, cdn);
+ frappe.model.set_value(cdt, cdn, 'stock_qty', row.qty * row.conversion_factor);
+ }
+});
+
+function get_item_details(item_code, uom=null) {
+ return frappe.xcall('erpnext.stock.doctype.pick_list.pick_list.get_item_details', {
+ item_code,
+ uom
+ });
+}
\ No newline at end of file
diff --git a/erpnext/stock/doctype/pick_list/pick_list.py b/erpnext/stock/doctype/pick_list/pick_list.py
index d5bf643..e12bd92 100644
--- a/erpnext/stock/doctype/pick_list/pick_list.py
+++ b/erpnext/stock/doctype/pick_list/pick_list.py
@@ -317,8 +317,15 @@
'pick_list': pick_list_name
})
-def get_item_details(item_code):
- pass
+@frappe.whitelist()
+def get_item_details(item_code, uom=None):
+ details = frappe.db.get_value('Item', item_code, ['stock_uom', 'name'], as_dict=1)
+ details.uom = uom or details.stock_uom
+ if uom:
+ details.update(get_conversion_factor(item_code, uom))
+
+ return details
+
def update_stock_entry_based_on_work_order(pick_list, stock_entry):
work_order = frappe.get_doc("Work Order", pick_list.get('work_order'))
diff --git a/erpnext/stock/doctype/pick_list_item/pick_list_item.json b/erpnext/stock/doctype/pick_list_item/pick_list_item.json
index 809f661..9477377 100644
--- a/erpnext/stock/doctype/pick_list_item/pick_list_item.json
+++ b/erpnext/stock/doctype/pick_list_item/pick_list_item.json
@@ -112,6 +112,7 @@
{
"fieldname": "stock_qty",
"fieldtype": "Float",
+ "in_list_view": 1,
"label": "Qty as per Stock UOM",
"read_only": 1
},
@@ -170,7 +171,7 @@
}
],
"istable": 1,
- "modified": "2019-08-26 22:19:56.872728",
+ "modified": "2019-08-27 08:44:04.173333",
"modified_by": "Administrator",
"module": "Stock",
"name": "Pick List Item",
diff --git a/erpnext/stock/doctype/pick_list_reference_item/pick_list_reference_item.json b/erpnext/stock/doctype/pick_list_reference_item/pick_list_reference_item.json
index 0b3c4dc..861e696 100644
--- a/erpnext/stock/doctype/pick_list_reference_item/pick_list_reference_item.json
+++ b/erpnext/stock/doctype/pick_list_reference_item/pick_list_reference_item.json
@@ -33,8 +33,8 @@
{
"fieldname": "stock_qty",
"fieldtype": "Float",
- "in_list_view": 1,
- "label": "Stock Qty"
+ "label": "Stock Qty",
+ "read_only": 1
},
{
"fieldname": "uom",
@@ -98,7 +98,7 @@
}
],
"istable": 1,
- "modified": "2019-08-26 23:02:52.470206",
+ "modified": "2019-08-27 08:40:21.870638",
"modified_by": "Administrator",
"module": "Stock",
"name": "Pick List Reference Item",