From 35047ac2831ced13709bdb6c3106c62b11fe5418 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 18 May 2016 18:16:36 +0530 Subject: [PATCH] [ux] direct editing in material request --- .../material_request/material_request.js | 19 +++++++++++++++++++ .../material_request/material_request.py | 6 +++--- .../form_grid/material_request_grid.html | 2 +- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js index 1dcbcb7916..2195a58a62 100644 --- a/erpnext/stock/doctype/material_request/material_request.js +++ b/erpnext/stock/doctype/material_request/material_request.js @@ -3,7 +3,26 @@ {% include 'erpnext/buying/doctype/purchase_common/purchase_common.js' %}; +frappe.ui.form.on('Material Request', { + setup: function(frm) { + frm.get_field('items').grid.editable_fields = [ + {fieldname: 'item_code', columns: 4}, + {fieldname: 'qty', columns: 3}, + {fieldname: 'uom', columns: 2}, + {fieldname: 'schedule_date', columns: 2}, + ]; + // formatter for material request item + frappe.meta.set_formatter('Material Request Item', 'item_code', frm.doc.name, + function(value, df, options, doc) { + return repl('%(name)s', { + color: (doc.qty<=doc.ordered_qty) ? "green" : "orange", + name: doc.item_code + }); + } + ); + } +}); frappe.ui.form.on("Material Request Item", { "qty": function(frm, doctype, name) { diff --git a/erpnext/stock/doctype/material_request/material_request.py b/erpnext/stock/doctype/material_request/material_request.py index a950180f6a..ef1c574669 100644 --- a/erpnext/stock/doctype/material_request/material_request.py +++ b/erpnext/stock/doctype/material_request/material_request.py @@ -15,9 +15,9 @@ from erpnext.controllers.buying_controller import BuyingController from erpnext.manufacturing.doctype.production_order.production_order import get_item_details -form_grid_templates = { - "items": "templates/form_grid/material_request_grid.html" -} +# form_grid_templates = { +# "items": "templates/form_grid/material_request_grid.html" +# } class MaterialRequest(BuyingController): def get_feed(self): diff --git a/erpnext/templates/form_grid/material_request_grid.html b/erpnext/templates/form_grid/material_request_grid.html index 866c06e586..282437aef2 100644 --- a/erpnext/templates/form_grid/material_request_grid.html +++ b/erpnext/templates/form_grid/material_request_grid.html @@ -11,7 +11,7 @@ {% } else { %}
- {%= doc.item_code %} + {%= doc.item_code %} {% if(doc.item_name != doc.item_code) { %}
{%= doc.item_name %}{% } %}