From ebd72897232d645bc9abbea3335cd869113ee6c2 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 25 Jan 2013 14:11:50 +0530 Subject: [PATCH] minimum width for fieldtype currency is 100px --- core/doctype/doctype/doctype.py | 4 ++++ public/js/legacy/widgets/form/grid.js | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/doctype/doctype/doctype.py b/core/doctype/doctype/doctype.py index 0243abba36..9cc3c6f393 100644 --- a/core/doctype/doctype/doctype.py +++ b/core/doctype/doctype/doctype.py @@ -206,6 +206,10 @@ def validate_fields(fields): if d.hidden and d.reqd: webnotes.msgprint("""#%(idx)s %(label)s: Cannot be hidden and mandatory (reqd)""" % d.fields, raise_exception=True) + + def check_width(d): + if d.fieldtype == "Currency" and cint(d.width) < 100: + webnotes.msgprint("Minimum width for FieldType 'Currency' is 100px", raise_exception=1) for d in fields: if not d.permlevel: d.permlevel = 0 diff --git a/public/js/legacy/widgets/form/grid.js b/public/js/legacy/widgets/form/grid.js index 94b9e034a6..4bf9fc586f 100644 --- a/public/js/legacy/widgets/form/grid.js +++ b/public/js/legacy/widgets/form/grid.js @@ -98,9 +98,9 @@ _f.Grid.prototype.insert_column = function(doctype, fieldname, fieldtype, label, var idx = this.head_row.cells.length; if(!width)width = '100px'; - if((width+'').slice(-2)!='px') { - width= width + 'px'; - } + if(fieldtype=="Currency" && cint(width) < 100) width = "100px"; + width= cint(width) + 'px'; + var col = this.head_row.insertCell(idx); col.doctype = doctype; // for report (fields may be from diff doctypes)