fix: Get items button

This commit is contained in:
Suraj Shetty 2019-08-19 10:38:01 +05:30
parent ec1fe9e2ca
commit 669cff88d1

View File

@ -14,24 +14,35 @@ frappe.ui.form.on('Pick List', {
},
refresh: (frm) => {
frm.add_custom_button(__('Delivery Note'), () => frm.trigger('make_delivery_note'), __('Create'));
frm.add_custom_button(__('Sales Order'), () => {
erpnext.utils.map_current_doc({
method: "erpnext.selling.doctype.sales_order.sales_order.make_pick_list",
source_doctype: "Sales Order",
target: frm,
setters: {
company: frm.doc.company,
},
get_query_filters: {
docstatus: 1,
}
});
}, __("Get items from"));
frm.add_custom_button(__('Work Order'), () => {
if (frm.doc.reference_items && frm.doc.reference_items.length) {
frm.add_custom_button(__('Get Item Locations'), () => {
frm.call('set_item_locations');
});
}
frm.trigger('add_get_items_button');
},
items_based_on: (frm) => {
frm.trigger('add_get_items_button');
},
make_delivery_note(frm) {
frappe.model.open_mapped_doc({
method: "erpnext.stock.doctype.pick_list.pick_list.make_delivery_note",
frm: frm
});
},
add_get_items_button(frm) {
frm.remove_custom_button(__("Get items"));
let source_doctype = frm.doc.items_based_on;
let method = 'erpnext.selling.doctype.sales_order.sales_order.make_pick_list';
if (source_doctype === 'Sales Order') {
method = 'erpnext.manufacturing.doctype.work_order.work_order.make_pick_list';
}
frm.add_custom_button(__("Get items"), () => {
erpnext.utils.map_current_doc({
method: "erpnext.manufacturing.doctype.work_order.work_order.make_pick_list",
source_doctype: "Work Order",
method: method,
source_doctype: source_doctype,
target: frm,
setters: {
company: frm.doc.company,
@ -41,18 +52,6 @@ frappe.ui.form.on('Pick List', {
docstatus: 1,
}
});
}, __("Get items from"));
if (frm.doc.reference_items && frm.doc.reference_items.length) {
frm.add_custom_button(__('Get Item Locations'), () => {
frm.call('set_item_locations');
});
}
},
make_delivery_note(frm) {
frappe.model.open_mapped_doc({
method: "erpnext.stock.doctype.pick_list.pick_list.make_delivery_note",
frm: frm
});
},
}
});