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>
This commit is contained in:
Marica
2020-04-21 13:13:39 +05:30
committed by GitHub
parent 27c6f69435
commit 9942acd9d4
6 changed files with 161 additions and 120 deletions

View File

@@ -444,18 +444,10 @@ erpnext.buying.get_items_from_product_bundle = function(frm) {
"fieldname": "quantity", "fieldname": "quantity",
"reqd": 1, "reqd": 1,
"default": 1 "default": 1
},
{
"fieldtype": "Button",
"label": __("Get Items"),
"fieldname": "get_items",
"cssClass": "btn-primary"
} }
] ],
}); primary_action_label: 'Get Items',
primary_action(args){
dialog.fields_dict.get_items.$input.click(function() {
var args = dialog.get_values();
if(!args) return; if(!args) return;
dialog.hide(); dialog.hide();
return frappe.call({ return frappe.call({
@@ -513,6 +505,8 @@ erpnext.buying.get_items_from_product_bundle = function(frm) {
} }
} }
}) })
}
}); });
dialog.show(); dialog.show();
} }

View File

@@ -85,7 +85,7 @@ def make_custom_fields(update=True):
hsn_sac_field = dict(fieldname='gst_hsn_code', label='HSN/SAC', hsn_sac_field = dict(fieldname='gst_hsn_code', label='HSN/SAC',
fieldtype='Data', fetch_from='item_code.gst_hsn_code', insert_after='description', fieldtype='Data', fetch_from='item_code.gst_hsn_code', insert_after='description',
allow_on_submit=1, print_hide=1, fetch_if_empty=1) 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', fieldtype='Check', fetch_from='item_code.is_nil_exempt', insert_after='gst_hsn_code',
print_hide=1) print_hide=1)
is_non_gst = dict(fieldname='is_non_gst', label='Is Non GST', is_non_gst = dict(fieldname='is_non_gst', label='Is Non GST',
@@ -388,7 +388,7 @@ def make_custom_fields(update=True):
'Item': [ 'Item': [
dict(fieldname='gst_hsn_code', label='HSN/SAC', dict(fieldname='gst_hsn_code', label='HSN/SAC',
fieldtype='Link', options='GST HSN Code', insert_after='item_group'), 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'), fieldtype='Check', insert_after='gst_hsn_code'),
dict(fieldname='is_non_gst', label='Is Non GST ', dict(fieldname='is_non_gst', label='Is Non GST ',
fieldtype='Check', insert_after='is_nil_exempt') fieldtype='Check', insert_after='is_nil_exempt')

View File

@@ -12,7 +12,8 @@ frappe.ui.form.on('Material Request', {
'Purchase Order': 'Purchase Order', 'Purchase Order': 'Purchase Order',
'Request for Quotation': 'Request for Quotation', 'Request for Quotation': 'Request for Quotation',
'Supplier Quotation': 'Supplier Quotation', 'Supplier Quotation': 'Supplier Quotation',
'Work Order': 'Work Order' 'Work Order': 'Work Order',
'Purchase Receipt': 'Purchase Receipt'
}; };
// formatter for material request item // formatter for material request item
@@ -27,11 +28,20 @@ frappe.ui.form.on('Material Request', {
// set schedule_date // set schedule_date
set_schedule_date(frm); 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 { return {
filters: {'company': doc.company} filters: filters
}; };
});
frm.set_query("set_warehouse", function(){
return {
filters: filters
}; };
});
}, },
onload_post_render: function(frm) { onload_post_render: function(frm) {
@@ -129,12 +139,13 @@ frappe.ui.form.on('Material Request', {
source_doctype: "Sales Order", source_doctype: "Sales Order",
target: frm, target: frm,
setters: { setters: {
company: frm.doc.company customer: frm.doc.customer || undefined
}, },
get_query_filters: { get_query_filters: {
docstatus: 1, docstatus: 1,
status: ["not in", ["Closed", "On Hold"]], status: ["not in", ["Closed", "On Hold"]],
per_delivered: ["<", 99.99], per_delivered: ["<", 99.99],
company: frm.doc.company
} }
}); });
}, },
@@ -182,17 +193,15 @@ frappe.ui.form.on('Material Request', {
options:"BOM", reqd: 1, get_query: function() { options:"BOM", reqd: 1, get_query: function() {
return {filters: { docstatus:1 }}; return {filters: { docstatus:1 }};
}}, }},
{"fieldname":"warehouse", "fieldtype":"Link", "label":__("Warehouse"), {"fieldname":"warehouse", "fieldtype":"Link", "label":__("For Warehouse"),
options:"Warehouse", reqd: 1}, options:"Warehouse", reqd: 1},
{"fieldname":"qty", "fieldtype":"Float", "label":__("Quantity"), {"fieldname":"qty", "fieldtype":"Float", "label":__("Quantity"),
reqd: 1, "default": 1}, reqd: 1, "default": 1},
{"fieldname":"fetch_exploded", "fieldtype":"Check", {"fieldname":"fetch_exploded", "fieldtype":"Check",
"label":__("Fetch exploded BOM (including sub-assemblies)"), "default":1}, "label":__("Fetch exploded BOM (including sub-assemblies)"), "default":1}
{fieldname:"fetch", "label":__("Get Items from BOM"), "fieldtype":"Button"} ],
] primary_action_label: 'Get Items',
}); primary_action(values) {
d.get_input("fetch").on("click", function() {
var values = d.get_values();
if(!values) return; if(!values) return;
values["company"] = frm.doc.company; values["company"] = frm.doc.company;
if(!frm.doc.company) frappe.throw(__("Company field is required")); if(!frm.doc.company) frappe.throw(__("Company field is required"));
@@ -221,7 +230,9 @@ frappe.ui.form.on('Material Request', {
refresh_field("items"); refresh_field("items");
} }
}); });
}
}); });
d.show(); d.show();
}, },
@@ -248,7 +259,8 @@ frappe.ui.form.on('Material Request', {
run_link_triggers: true run_link_triggers: true
}); });
}, },
__('Enter Supplier') __('Enter Supplier'),
__('Create')
) )
}, },

View File

@@ -1,9 +1,11 @@
{ {
"actions": [],
"allow_import": 1, "allow_import": 1,
"autoname": "naming_series:", "autoname": "naming_series:",
"creation": "2013-03-07 14:48:38", "creation": "2013-03-07 14:48:38",
"doctype": "DocType", "doctype": "DocType",
"document_type": "Document", "document_type": "Document",
"engine": "InnoDB",
"field_order": [ "field_order": [
"type_section", "type_section",
"naming_series", "naming_series",
@@ -14,6 +16,8 @@
"schedule_date", "schedule_date",
"company", "company",
"amended_from", "amended_from",
"warehouse_section",
"set_warehouse",
"items_section", "items_section",
"scan_barcode", "scan_barcode",
"items", "items",
@@ -66,7 +70,7 @@
"fieldtype": "Select", "fieldtype": "Select",
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 1, "in_standard_filter": 1,
"label": "Type", "label": "Purpose",
"options": "Purchase\nMaterial Transfer\nMaterial Issue\nManufacture\nCustomer Provided", "options": "Purchase\nMaterial Transfer\nMaterial Issue\nManufacture\nCustomer Provided",
"reqd": 1 "reqd": 1
}, },
@@ -85,7 +89,7 @@
"allow_on_submit": 1, "allow_on_submit": 1,
"fieldname": "schedule_date", "fieldname": "schedule_date",
"fieldtype": "Date", "fieldtype": "Date",
"label": "Required Date" "label": "Required By"
}, },
{ {
"fieldname": "company", "fieldname": "company",
@@ -190,6 +194,7 @@
"width": "100px" "width": "100px"
}, },
{ {
"depends_on": "eval:doc.docstatus==1",
"fieldname": "per_ordered", "fieldname": "per_ordered",
"fieldtype": "Percent", "fieldtype": "Percent",
"label": "% Ordered", "label": "% Ordered",
@@ -200,6 +205,7 @@
"read_only": 1 "read_only": 1
}, },
{ {
"depends_on": "eval:doc.docstatus==1",
"fieldname": "per_received", "fieldname": "per_received",
"fieldtype": "Percent", "fieldtype": "Percent",
"label": "% Received", "label": "% Received",
@@ -270,12 +276,24 @@
"options": "Job Card", "options": "Job Card",
"print_hide": 1, "print_hide": 1,
"read_only": 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", "icon": "fa fa-ticket",
"idx": 70, "idx": 70,
"is_submittable": 1, "is_submittable": 1,
"modified": "2019-04-29 11:45:07.570292", "links": [],
"modified": "2020-03-02 20:21:09.990867",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Material Request", "name": "Material Request",

View File

@@ -8,7 +8,12 @@ def get_data():
'transactions': [ 'transactions': [
{ {
'label': _('Related'), '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'), 'label': _('Manufacturing'),

View File

@@ -7,36 +7,38 @@
"engine": "InnoDB", "engine": "InnoDB",
"field_order": [ "field_order": [
"item_code", "item_code",
"col_break1",
"item_name", "item_name",
"col_break1",
"schedule_date",
"section_break_4", "section_break_4",
"description", "description",
"item_group", "item_group",
"brand", "brand",
"image_section", "image_section",
"image", "image",
"manufacture_details",
"manufacturer",
"column_break_12", "column_break_12",
"manufacturer_part_no", "manufacturer_part_no",
"quantity_and_warehouse", "quantity_and_warehouse",
"qty", "qty",
"uom",
"conversion_factor",
"stock_uom", "stock_uom",
"warehouse", "warehouse",
"col_break2", "col_break2",
"schedule_date", "uom",
"rate", "conversion_factor",
"amount",
"stock_qty", "stock_qty",
"rate_and_amount_section_break",
"rate",
"col_break3",
"amount",
"manufacture_details",
"manufacturer",
"more_info", "more_info",
"lead_time_date", "lead_time_date",
"sales_order", "sales_order",
"sales_order_item", "sales_order_item",
"production_plan", "production_plan",
"material_request_plan_item", "material_request_plan_item",
"col_break3", "col_break4",
"min_order_qty", "min_order_qty",
"projected_qty", "projected_qty",
"actual_qty", "actual_qty",
@@ -175,7 +177,7 @@
"fieldname": "schedule_date", "fieldname": "schedule_date",
"fieldtype": "Date", "fieldtype": "Date",
"in_list_view": 1, "in_list_view": 1,
"label": "Required Date", "label": "Required By",
"oldfieldname": "schedule_date", "oldfieldname": "schedule_date",
"oldfieldtype": "Date", "oldfieldtype": "Date",
"print_width": "100px", "print_width": "100px",
@@ -185,14 +187,12 @@
{ {
"fieldname": "rate", "fieldname": "rate",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Rate", "label": "Rate"
"no_copy": 1
}, },
{ {
"fieldname": "amount", "fieldname": "amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Amount", "label": "Amount",
"no_copy": 1,
"read_only": 1 "read_only": 1
}, },
{ {
@@ -204,6 +204,7 @@
"read_only": 1 "read_only": 1
}, },
{ {
"collapsible": 1,
"fieldname": "more_info", "fieldname": "more_info",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "More Information" "label": "More Information"
@@ -331,6 +332,7 @@
"read_only": 1 "read_only": 1
}, },
{ {
"collapsible": 1,
"fieldname": "accounting_details", "fieldname": "accounting_details",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Accounting Details" "label": "Accounting Details"
@@ -389,6 +391,7 @@
"fieldtype": "Column Break" "fieldtype": "Column Break"
}, },
{ {
"collapsible": 1,
"fieldname": "manufacture_details", "fieldname": "manufacture_details",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Manufacture" "label": "Manufacture"
@@ -406,7 +409,16 @@
{ {
"fieldname": "manufacturer_part_no", "fieldname": "manufacturer_part_no",
"fieldtype": "Data", "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, "idx": 1,