fix [ux]: Material Request Form Cleanup and UX (#20810)
* fix (ux): Material Request Form Cleanup
* fix: Get Items from popup UX
Co-authored-by: Nabin Hait <nabinhait@gmail.com>
diff --git a/erpnext/public/js/controllers/buying.js b/erpnext/public/js/controllers/buying.js
index afbdbc6..d5dc412 100644
--- a/erpnext/public/js/controllers/buying.js
+++ b/erpnext/public/js/controllers/buying.js
@@ -444,75 +444,69 @@
"fieldname": "quantity",
"reqd": 1,
"default": 1
- },
- {
- "fieldtype": "Button",
- "label": __("Get Items"),
- "fieldname": "get_items",
- "cssClass": "btn-primary"
}
- ]
- });
-
- dialog.fields_dict.get_items.$input.click(function() {
- var args = dialog.get_values();
- if(!args) return;
- dialog.hide();
- return frappe.call({
- type: "GET",
- method: "erpnext.stock.doctype.packed_item.packed_item.get_items_from_product_bundle",
- args: {
+ ],
+ primary_action_label: 'Get Items',
+ primary_action(args){
+ if(!args) return;
+ dialog.hide();
+ return frappe.call({
+ type: "GET",
+ method: "erpnext.stock.doctype.packed_item.packed_item.get_items_from_product_bundle",
args: {
- item_code: args.product_bundle,
- quantity: args.quantity,
- parenttype: frm.doc.doctype,
- parent: frm.doc.name,
- supplier: frm.doc.supplier,
- currency: frm.doc.currency,
- conversion_rate: frm.doc.conversion_rate,
- price_list: frm.doc.buying_price_list,
- price_list_currency: frm.doc.price_list_currency,
- plc_conversion_rate: frm.doc.plc_conversion_rate,
- company: frm.doc.company,
- is_subcontracted: frm.doc.is_subcontracted,
- transaction_date: frm.doc.transaction_date || frm.doc.posting_date,
- ignore_pricing_rule: frm.doc.ignore_pricing_rule,
- doctype: frm.doc.doctype
- }
- },
- freeze: true,
- callback: function(r) {
- const first_row_is_empty = function(child_table){
- if($.isArray(child_table) && child_table.length > 0) {
- return !child_table[0].item_code;
+ args: {
+ item_code: args.product_bundle,
+ quantity: args.quantity,
+ parenttype: frm.doc.doctype,
+ parent: frm.doc.name,
+ supplier: frm.doc.supplier,
+ currency: frm.doc.currency,
+ conversion_rate: frm.doc.conversion_rate,
+ price_list: frm.doc.buying_price_list,
+ price_list_currency: frm.doc.price_list_currency,
+ plc_conversion_rate: frm.doc.plc_conversion_rate,
+ company: frm.doc.company,
+ is_subcontracted: frm.doc.is_subcontracted,
+ transaction_date: frm.doc.transaction_date || frm.doc.posting_date,
+ ignore_pricing_rule: frm.doc.ignore_pricing_rule,
+ doctype: frm.doc.doctype
}
- return false;
- };
+ },
+ freeze: true,
+ callback: function(r) {
+ const first_row_is_empty = function(child_table){
+ if($.isArray(child_table) && child_table.length > 0) {
+ return !child_table[0].item_code;
+ }
+ return false;
+ };
- const remove_empty_first_row = function(frm){
- if (first_row_is_empty(frm.doc.items)){
- frm.doc.items = frm.doc.items.splice(1);
- }
- };
+ const remove_empty_first_row = function(frm){
+ if (first_row_is_empty(frm.doc.items)){
+ frm.doc.items = frm.doc.items.splice(1);
+ }
+ };
- if(!r.exc && r.message) {
- remove_empty_first_row(frm);
- for ( var i=0; i< r.message.length; i++ ) {
- var d = frm.add_child("items");
- var item = r.message[i];
- for ( var key in item) {
- if ( !is_null(item[key]) ) {
- d[key] = item[key];
+ if(!r.exc && r.message) {
+ remove_empty_first_row(frm);
+ for ( var i=0; i< r.message.length; i++ ) {
+ var d = frm.add_child("items");
+ var item = r.message[i];
+ for ( var key in item) {
+ if ( !is_null(item[key]) ) {
+ d[key] = item[key];
+ }
+ }
+ if(frappe.meta.get_docfield(d.doctype, "price_list_rate", d.name)) {
+ frm.script_manager.trigger("price_list_rate", d.doctype, d.name);
}
}
- if(frappe.meta.get_docfield(d.doctype, "price_list_rate", d.name)) {
- frm.script_manager.trigger("price_list_rate", d.doctype, d.name);
- }
+ frm.refresh_field("items");
}
- frm.refresh_field("items");
}
- }
- })
+ })
+ }
});
+
dialog.show();
}
diff --git a/erpnext/regional/india/setup.py b/erpnext/regional/india/setup.py
index ae6f4dd..4be6804 100644
--- a/erpnext/regional/india/setup.py
+++ b/erpnext/regional/india/setup.py
@@ -85,7 +85,7 @@
hsn_sac_field = dict(fieldname='gst_hsn_code', label='HSN/SAC',
fieldtype='Data', fetch_from='item_code.gst_hsn_code', insert_after='description',
allow_on_submit=1, print_hide=1, fetch_if_empty=1)
- nil_rated_exempt = dict(fieldname='is_nil_exempt', label='Is nil rated or exempted',
+ nil_rated_exempt = dict(fieldname='is_nil_exempt', label='Is Nil Rated or Exempted',
fieldtype='Check', fetch_from='item_code.is_nil_exempt', insert_after='gst_hsn_code',
print_hide=1)
is_non_gst = dict(fieldname='is_non_gst', label='Is Non GST',
@@ -388,7 +388,7 @@
'Item': [
dict(fieldname='gst_hsn_code', label='HSN/SAC',
fieldtype='Link', options='GST HSN Code', insert_after='item_group'),
- dict(fieldname='is_nil_exempt', label='Is nil rated or exempted',
+ dict(fieldname='is_nil_exempt', label='Is Nil Rated or Exempted',
fieldtype='Check', insert_after='gst_hsn_code'),
dict(fieldname='is_non_gst', label='Is Non GST ',
fieldtype='Check', insert_after='is_nil_exempt')
diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js
index 6110ea8..b97da69 100644
--- a/erpnext/stock/doctype/material_request/material_request.js
+++ b/erpnext/stock/doctype/material_request/material_request.js
@@ -12,7 +12,8 @@
'Purchase Order': 'Purchase Order',
'Request for Quotation': 'Request for Quotation',
'Supplier Quotation': 'Supplier Quotation',
- 'Work Order': 'Work Order'
+ 'Work Order': 'Work Order',
+ 'Purchase Receipt': 'Purchase Receipt'
};
// formatter for material request item
@@ -27,11 +28,20 @@
// set schedule_date
set_schedule_date(frm);
- frm.fields_dict["items"].grid.get_field("warehouse").get_query = function(doc) {
+
+ let filters = {'company': frm.doc.company}
+
+ frm.set_query("warehouse", "items", function() {
return {
- filters: {'company': doc.company}
+ filters: filters
};
- };
+ });
+
+ frm.set_query("set_warehouse", function(){
+ return {
+ filters: filters
+ };
+ });
},
onload_post_render: function(frm) {
@@ -129,12 +139,13 @@
source_doctype: "Sales Order",
target: frm,
setters: {
- company: frm.doc.company
+ customer: frm.doc.customer || undefined
},
get_query_filters: {
docstatus: 1,
status: ["not in", ["Closed", "On Hold"]],
per_delivered: ["<", 99.99],
+ company: frm.doc.company
}
});
},
@@ -182,46 +193,46 @@
options:"BOM", reqd: 1, get_query: function() {
return {filters: { docstatus:1 }};
}},
- {"fieldname":"warehouse", "fieldtype":"Link", "label":__("Warehouse"),
+ {"fieldname":"warehouse", "fieldtype":"Link", "label":__("For Warehouse"),
options:"Warehouse", reqd: 1},
{"fieldname":"qty", "fieldtype":"Float", "label":__("Quantity"),
reqd: 1, "default": 1},
{"fieldname":"fetch_exploded", "fieldtype":"Check",
- "label":__("Fetch exploded BOM (including sub-assemblies)"), "default":1},
- {fieldname:"fetch", "label":__("Get Items from BOM"), "fieldtype":"Button"}
- ]
- });
- d.get_input("fetch").on("click", function() {
- var values = d.get_values();
- if(!values) return;
- values["company"] = frm.doc.company;
- if(!frm.doc.company) frappe.throw(__("Company field is required"));
- frappe.call({
- method: "erpnext.manufacturing.doctype.bom.bom.get_bom_items",
- args: values,
- callback: function(r) {
- if (!r.message) {
- frappe.throw(__("BOM does not contain any stock item"));
- } else {
- erpnext.utils.remove_empty_first_row(frm, "items");
- $.each(r.message, function(i, item) {
- var d = frappe.model.add_child(cur_frm.doc, "Material Request Item", "items");
- d.item_code = item.item_code;
- d.item_name = item.item_name;
- d.description = item.description;
- d.warehouse = values.warehouse;
- d.uom = item.stock_uom;
- d.stock_uom = item.stock_uom;
- d.conversion_factor = 1;
- d.qty = item.qty;
- d.project = item.project;
- });
+ "label":__("Fetch exploded BOM (including sub-assemblies)"), "default":1}
+ ],
+ primary_action_label: 'Get Items',
+ primary_action(values) {
+ if(!values) return;
+ values["company"] = frm.doc.company;
+ if(!frm.doc.company) frappe.throw(__("Company field is required"));
+ frappe.call({
+ method: "erpnext.manufacturing.doctype.bom.bom.get_bom_items",
+ args: values,
+ callback: function(r) {
+ if (!r.message) {
+ frappe.throw(__("BOM does not contain any stock item"));
+ } else {
+ erpnext.utils.remove_empty_first_row(frm, "items");
+ $.each(r.message, function(i, item) {
+ var d = frappe.model.add_child(cur_frm.doc, "Material Request Item", "items");
+ d.item_code = item.item_code;
+ d.item_name = item.item_name;
+ d.description = item.description;
+ d.warehouse = values.warehouse;
+ d.uom = item.stock_uom;
+ d.stock_uom = item.stock_uom;
+ d.conversion_factor = 1;
+ d.qty = item.qty;
+ d.project = item.project;
+ });
+ }
+ d.hide();
+ refresh_field("items");
}
- d.hide();
- refresh_field("items");
- }
- });
+ });
+ }
});
+
d.show();
},
@@ -248,7 +259,8 @@
run_link_triggers: true
});
},
- __('Enter Supplier')
+ __('Enter Supplier'),
+ __('Create')
)
},
diff --git a/erpnext/stock/doctype/material_request/material_request.json b/erpnext/stock/doctype/material_request/material_request.json
index d0025d1..536f5fa 100644
--- a/erpnext/stock/doctype/material_request/material_request.json
+++ b/erpnext/stock/doctype/material_request/material_request.json
@@ -1,9 +1,11 @@
{
+ "actions": [],
"allow_import": 1,
"autoname": "naming_series:",
"creation": "2013-03-07 14:48:38",
"doctype": "DocType",
"document_type": "Document",
+ "engine": "InnoDB",
"field_order": [
"type_section",
"naming_series",
@@ -14,6 +16,8 @@
"schedule_date",
"company",
"amended_from",
+ "warehouse_section",
+ "set_warehouse",
"items_section",
"scan_barcode",
"items",
@@ -66,7 +70,7 @@
"fieldtype": "Select",
"in_list_view": 1,
"in_standard_filter": 1,
- "label": "Type",
+ "label": "Purpose",
"options": "Purchase\nMaterial Transfer\nMaterial Issue\nManufacture\nCustomer Provided",
"reqd": 1
},
@@ -85,7 +89,7 @@
"allow_on_submit": 1,
"fieldname": "schedule_date",
"fieldtype": "Date",
- "label": "Required Date"
+ "label": "Required By"
},
{
"fieldname": "company",
@@ -190,6 +194,7 @@
"width": "100px"
},
{
+ "depends_on": "eval:doc.docstatus==1",
"fieldname": "per_ordered",
"fieldtype": "Percent",
"label": "% Ordered",
@@ -200,6 +205,7 @@
"read_only": 1
},
{
+ "depends_on": "eval:doc.docstatus==1",
"fieldname": "per_received",
"fieldtype": "Percent",
"label": "% Received",
@@ -270,12 +276,24 @@
"options": "Job Card",
"print_hide": 1,
"read_only": 1
+ },
+ {
+ "fieldname": "warehouse_section",
+ "fieldtype": "Section Break"
+ },
+ {
+ "description": "Sets 'For Warehouse' in each row of the Items table.",
+ "fieldname": "set_warehouse",
+ "fieldtype": "Link",
+ "label": "Set Warehouse",
+ "options": "Warehouse"
}
],
"icon": "fa fa-ticket",
"idx": 70,
"is_submittable": 1,
- "modified": "2019-04-29 11:45:07.570292",
+ "links": [],
+ "modified": "2020-03-02 20:21:09.990867",
"modified_by": "Administrator",
"module": "Stock",
"name": "Material Request",
diff --git a/erpnext/stock/doctype/material_request/material_request_dashboard.py b/erpnext/stock/doctype/material_request/material_request_dashboard.py
index cbd6478..0e4fb7a 100644
--- a/erpnext/stock/doctype/material_request/material_request_dashboard.py
+++ b/erpnext/stock/doctype/material_request/material_request_dashboard.py
@@ -8,7 +8,12 @@
'transactions': [
{
'label': _('Related'),
- 'items': ['Request for Quotation', 'Supplier Quotation', 'Purchase Order', 'Stock Entry', 'Pick List']
+ 'items': ['Request for Quotation', 'Supplier Quotation', 'Purchase Order']
+ },
+ {
+ 'label': _('Stock'),
+ 'items': ['Stock Entry', 'Purchase Receipt', 'Pick List']
+
},
{
'label': _('Manufacturing'),
diff --git a/erpnext/stock/doctype/material_request_item/material_request_item.json b/erpnext/stock/doctype/material_request_item/material_request_item.json
index 5604913..2bdc268 100644
--- a/erpnext/stock/doctype/material_request_item/material_request_item.json
+++ b/erpnext/stock/doctype/material_request_item/material_request_item.json
@@ -7,36 +7,38 @@
"engine": "InnoDB",
"field_order": [
"item_code",
- "col_break1",
"item_name",
+ "col_break1",
+ "schedule_date",
"section_break_4",
"description",
"item_group",
"brand",
"image_section",
"image",
- "manufacture_details",
- "manufacturer",
"column_break_12",
"manufacturer_part_no",
"quantity_and_warehouse",
"qty",
- "uom",
- "conversion_factor",
"stock_uom",
"warehouse",
"col_break2",
- "schedule_date",
- "rate",
- "amount",
+ "uom",
+ "conversion_factor",
"stock_qty",
+ "rate_and_amount_section_break",
+ "rate",
+ "col_break3",
+ "amount",
+ "manufacture_details",
+ "manufacturer",
"more_info",
"lead_time_date",
"sales_order",
"sales_order_item",
"production_plan",
"material_request_plan_item",
- "col_break3",
+ "col_break4",
"min_order_qty",
"projected_qty",
"actual_qty",
@@ -175,7 +177,7 @@
"fieldname": "schedule_date",
"fieldtype": "Date",
"in_list_view": 1,
- "label": "Required Date",
+ "label": "Required By",
"oldfieldname": "schedule_date",
"oldfieldtype": "Date",
"print_width": "100px",
@@ -185,14 +187,12 @@
{
"fieldname": "rate",
"fieldtype": "Currency",
- "label": "Rate",
- "no_copy": 1
+ "label": "Rate"
},
{
"fieldname": "amount",
"fieldtype": "Currency",
"label": "Amount",
- "no_copy": 1,
"read_only": 1
},
{
@@ -204,6 +204,7 @@
"read_only": 1
},
{
+ "collapsible": 1,
"fieldname": "more_info",
"fieldtype": "Section Break",
"label": "More Information"
@@ -331,6 +332,7 @@
"read_only": 1
},
{
+ "collapsible": 1,
"fieldname": "accounting_details",
"fieldtype": "Section Break",
"label": "Accounting Details"
@@ -389,6 +391,7 @@
"fieldtype": "Column Break"
},
{
+ "collapsible": 1,
"fieldname": "manufacture_details",
"fieldtype": "Section Break",
"label": "Manufacture"
@@ -406,7 +409,16 @@
{
"fieldname": "manufacturer_part_no",
"fieldtype": "Data",
- "label": "Manufacturer Part Number"
+ "label": "Manufacturer Part Number",
+ "read_only": 1
+ },
+ {
+ "fieldname": "rate_and_amount_section_break",
+ "fieldtype": "Section Break"
+ },
+ {
+ "fieldname": "col_break4",
+ "fieldtype": "Column Break"
}
],
"idx": 1,