fix: Update item detail for items without reference
This commit is contained in:
parent
dc675b1eb0
commit
974ac3e6ad
@ -521,7 +521,6 @@ def create_pick_list(source_name, target_doc=None):
|
||||
'name': 'material_request_item',
|
||||
'qty': 'stock_qty'
|
||||
},
|
||||
# 'condition': lambda doc: abs(doc.transferred_qty) < abs(doc.required_qty)
|
||||
},
|
||||
}, target_doc)
|
||||
|
||||
|
@ -27,7 +27,7 @@ frappe.ui.form.on('Pick List', {
|
||||
};
|
||||
});
|
||||
},
|
||||
get_item_locations(frm) {
|
||||
get_item_locations: (frm) => {
|
||||
frm.call('set_item_locations');
|
||||
},
|
||||
refresh: (frm) => {
|
||||
@ -84,18 +84,22 @@ frappe.ui.form.on('Pick List', {
|
||||
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.ui.form.on('Pick List', {
|
||||
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 @@ frappe.ui.form.on('Pick List', {
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
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
|
||||
});
|
||||
}
|
@ -317,8 +317,15 @@ def stock_entry_exists(pick_list_name):
|
||||
'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'))
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user