Skip to content

Instantly share code, notes, and snippets.

@rmehta
Created February 17, 2015 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmehta/13f20e4ec24061d2e5f8 to your computer and use it in GitHub Desktop.
Save rmehta/13f20e4ec24061d2e5f8 to your computer and use it in GitHub Desktop.
Frappe Version 5 Client Side API
// button click "Get Items"
frappe.ui.form.on("Stock Reconciliation", "get_items", function(frm) {
// prompt user for warehouse
frappe.prompt({label:"Warehouse", fieldtype:"Link", options:"Warehouse", reqd: 1},
function(data) {
// get latest balance and valuation rate
frappe.call({
method:"erpnext.stock.doctype.stock_reconciliation.stock_reconciliation.get_items",
args: {warehouse: data.warehouse},
callback: function(r) {
// set the values in the item table
var items = [];
frm.clear_table("items");
for(var i=0; i< r.message.length; i++) {
var d = frm.add_child("items");
$.extend(d, r.message[i]);
}
frm.refresh_field("items");
}
});
}
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment