diff --git a/frappe/core/doctype/doctype/doctype.py b/frappe/core/doctype/doctype/doctype.py index 12881163db..cccd603fcf 100644 --- a/frappe/core/doctype/doctype/doctype.py +++ b/frappe/core/doctype/doctype/doctype.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals -import re +import re, copy import MySQLdb import frappe from frappe import _ @@ -311,7 +311,7 @@ def validate_fields(meta): frappe.throw(_("Max width for type Currency is 100px in row {0}").format(d.idx)) def check_in_list_view(d): - if d.in_list_view and (d.fieldtype in no_value_fields): + if d.in_list_view and (d.fieldtype in not_allowed_in_list_view): frappe.throw(_("'In List View' not allowed for type {0} in row {1}").format(d.fieldtype, d.idx)) def check_dynamic_link_options(d): @@ -441,6 +441,10 @@ def validate_fields(meta): frappe.throw(_("Timeline field must be a Link or Dynamic Link"), InvalidFieldNameError) fields = meta.get("fields") + not_allowed_in_list_view = list(copy.copy(no_value_fields)) + if meta.istable: + not_allowed_in_list_view.remove('Button') + for d in fields: if not d.permlevel: d.permlevel = 0 if not d.fieldname: diff --git a/frappe/public/css/form_grid.css b/frappe/public/css/form_grid.css index 9fe46620be..57a4319ca8 100644 --- a/frappe/public/css/form_grid.css +++ b/frappe/public/css/form_grid.css @@ -104,8 +104,19 @@ .grid-body .editable-row input[data-fieldtype="Currency"] { text-align: right; } +.grid-body .grid-static-col[data-fieldtype="Button"] .field-area { + margin-top: 5px; + margin-left: 5px; +} +.grid-body .grid-static-col[data-fieldtype="Button"] .field-area button { + height: 27px; +} .grid-body .grid-static-col[data-fieldtype="Code"] .static-area { - margin-top: -10px; + margin-top: -5px; +} +.grid-body .grid-static-col[data-fieldtype="Code"] .static-area pre { + background: none; + border: none; } @media (max-width: 767px) { .grid-body .btn-open-row { diff --git a/frappe/public/js/frappe/form/grid.js b/frappe/public/js/frappe/form/grid.js index 52946250ec..55f3ab594b 100644 --- a/frappe/public/js/frappe/form/grid.js +++ b/frappe/public/js/frappe/form/grid.js @@ -291,12 +291,17 @@ frappe.ui.form.Grid = Class.extend({ this.frm.script_manager.trigger(this.df.fieldname + "_add", d.doctype, d.name); this.refresh(); - if(show && !this.allow_on_grid_editing()) { + if(show) { if(idx) { + // always open inserted rows this.wrapper.find("[data-idx='"+idx+"']").data("grid_row") .toggle_view(true, callback); } else { - this.wrapper.find(".grid-row:last").data("grid_row").toggle_view(true, callback); + if(!this.allow_on_grid_editing()) { + // open last row only if on-grid-editing is disabled + this.wrapper.find(".grid-row:last").data("grid_row") + .toggle_view(true, callback); + } } } diff --git a/frappe/public/less/form_grid.less b/frappe/public/less/form_grid.less index 2a8d76c313..ea09b57309 100644 --- a/frappe/public/less/form_grid.less +++ b/frappe/public/less/form_grid.less @@ -136,8 +136,22 @@ } } + .grid-static-col[data-fieldtype="Button"] .field-area { + margin-top: 5px; + margin-left: 5px; + + button { + height: 27px; + } + } + .grid-static-col[data-fieldtype="Code"] .static-area { - margin-top: -10px; + margin-top: -5px; + + pre { + background: none; + border: none; + } } } diff --git a/frappe/utils/data.py b/frappe/utils/data.py index ca6a689584..3d2cc05dea 100644 --- a/frappe/utils/data.py +++ b/frappe/utils/data.py @@ -114,6 +114,10 @@ def now_datetime(): dt = convert_utc_to_user_timezone(datetime.datetime.utcnow()) return dt.replace(tzinfo=None) +def get_eta(from_time, percent_complete): + diff = time_diff(now_datetime(), from_time).total_seconds() + return str(datetime.timedelta(seconds=(100 - percent_complete) / percent_complete * diff)) + def _get_time_zone(): return frappe.db.get_system_setting('time_zone') or 'Asia/Kolkata'