fix : Create Pick List Fos Sales Order List (#20915)

Co-authored-by: Dharmraj <Dharmraj@bloomstack.com>
Co-authored-by: Nabin Hait <nabinhait@gmail.com>
This commit is contained in:
Dharmraj-48 2020-04-21 13:10:09 +05:30 committed by GitHub
parent 34bbd5b612
commit 27c6f69435
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,6 +47,41 @@ frappe.listview_settings['Sales Order'] = {
listview.page.add_menu_item(__("Re-open"), function() {
listview.call_for_selected_items(method, {"status": "Submitted"});
});
},
onload: function(doclist) {
const action = () => {
const selected_docs = doclist.get_checked_items();
const docnames = doclist.get_checked_items(true);
if (selected_docs.length > 0) {
for (let doc of selected_docs) {
if (!doc.docstatus) {
frappe.throw(__("Cannot create a Pick List from Draft documents."));
}
};
frappe.new_doc("Pick List")
.then(() => {
frappe.call({
type: "POST",
method: "frappe.model.mapper.map_docs",
args: {
"method": "erpnext.selling.doctype.sales_order.sales_order.create_pick_list",
"source_names": docnames,
"target_doc": cur_frm.doc
},
callback: function (r) {
if (!r.exc) {
frappe.model.sync(r.message);
cur_frm.dirty();
cur_frm.refresh();
}
}
});
})
};
};
doclist.page.add_actions_menu_item(__('Create Pick List'), action, false);
}
};