From 38b930b638f10888b629c02284813212dc36e5d7 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Fri, 5 Jul 2019 10:38:48 +0530 Subject: [PATCH] refactor: Move and Add buttons open new stock entry --- erpnext/stock/dashboard/item_dashboard.js | 25 +++++++++++++++++++ .../stock/dashboard/item_dashboard_list.html | 15 +++++++++++ 2 files changed, 40 insertions(+) diff --git a/erpnext/stock/dashboard/item_dashboard.js b/erpnext/stock/dashboard/item_dashboard.js index f820b7aa86..ed325a16b8 100644 --- a/erpnext/stock/dashboard/item_dashboard.js +++ b/erpnext/stock/dashboard/item_dashboard.js @@ -16,6 +16,31 @@ erpnext.stock.ItemDashboard = Class.extend({ this.content = $(frappe.render_template('item_dashboard')).appendTo(this.parent); this.result = this.content.find('.result'); + this.content.on('click', '.btn-move', function() { + let item = unescape($(this).attr('data-item')); + let warehouse = unescape($(this).attr('data-warehouse')); + open_stock_entry(item, warehouse, "Material Transfer"); + }); + + this.content.on('click', '.btn-add', function() { + let item = unescape($(this).attr('data-item')); + let warehouse = unescape($(this).attr('data-warehouse')); + open_stock_entry(item, warehouse); + }); + + function open_stock_entry(item, warehouse, entry_type) { + frappe.model.with_doctype('Stock Entry', function() { + var doc = frappe.model.get_new_doc('Stock Entry'); + if (entry_type) doc.stock_entry_type = entry_type; + + var row = frappe.model.add_child(doc, 'items'); + row.item_code = item; + row.s_warehouse = warehouse; + + frappe.set_route('Form', doc.doctype, doc.name); + }) + } + // more this.content.find('.btn-more').on('click', function() { me.start += 20; diff --git a/erpnext/stock/dashboard/item_dashboard_list.html b/erpnext/stock/dashboard/item_dashboard_list.html index f0e87b1c53..5a3fa2ed48 100644 --- a/erpnext/stock/dashboard/item_dashboard_list.html +++ b/erpnext/stock/dashboard/item_dashboard_list.html @@ -39,6 +39,21 @@ + {% if can_write %} +
+ {% if d.actual_qty %} +
+ {% endif %} {% endfor %}