@@ -3,7 +3,7 @@ | |||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import re | |||||
import re, copy | |||||
import MySQLdb | import MySQLdb | ||||
import frappe | import frappe | ||||
from frappe import _ | 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)) | frappe.throw(_("Max width for type Currency is 100px in row {0}").format(d.idx)) | ||||
def check_in_list_view(d): | 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)) | frappe.throw(_("'In List View' not allowed for type {0} in row {1}").format(d.fieldtype, d.idx)) | ||||
def check_dynamic_link_options(d): | 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) | frappe.throw(_("Timeline field must be a Link or Dynamic Link"), InvalidFieldNameError) | ||||
fields = meta.get("fields") | 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: | for d in fields: | ||||
if not d.permlevel: d.permlevel = 0 | if not d.permlevel: d.permlevel = 0 | ||||
if not d.fieldname: | if not d.fieldname: | ||||
@@ -104,8 +104,19 @@ | |||||
.grid-body .editable-row input[data-fieldtype="Currency"] { | .grid-body .editable-row input[data-fieldtype="Currency"] { | ||||
text-align: right; | 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 { | .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) { | @media (max-width: 767px) { | ||||
.grid-body .btn-open-row { | .grid-body .btn-open-row { | ||||
@@ -291,12 +291,17 @@ frappe.ui.form.Grid = Class.extend({ | |||||
this.frm.script_manager.trigger(this.df.fieldname + "_add", d.doctype, d.name); | this.frm.script_manager.trigger(this.df.fieldname + "_add", d.doctype, d.name); | ||||
this.refresh(); | this.refresh(); | ||||
if(show && !this.allow_on_grid_editing()) { | |||||
if(show) { | |||||
if(idx) { | if(idx) { | ||||
// always open inserted rows | |||||
this.wrapper.find("[data-idx='"+idx+"']").data("grid_row") | this.wrapper.find("[data-idx='"+idx+"']").data("grid_row") | ||||
.toggle_view(true, callback); | .toggle_view(true, callback); | ||||
} else { | } 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); | |||||
} | |||||
} | } | ||||
} | } | ||||
@@ -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 { | .grid-static-col[data-fieldtype="Code"] .static-area { | ||||
margin-top: -10px; | |||||
margin-top: -5px; | |||||
pre { | |||||
background: none; | |||||
border: none; | |||||
} | |||||
} | } | ||||
} | } | ||||
@@ -114,6 +114,10 @@ def now_datetime(): | |||||
dt = convert_utc_to_user_timezone(datetime.datetime.utcnow()) | dt = convert_utc_to_user_timezone(datetime.datetime.utcnow()) | ||||
return dt.replace(tzinfo=None) | 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(): | def _get_time_zone(): | ||||
return frappe.db.get_system_setting('time_zone') or 'Asia/Kolkata' | return frappe.db.get_system_setting('time_zone') or 'Asia/Kolkata' | ||||