diff --git a/core/page/data_import_tool/data_import_tool.html b/core/page/data_import_tool/data_import_tool.html deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/core/page/data_import_tool/data_import_tool.js b/core/page/data_import_tool/data_import_tool.js index 46a6c57e29..a8d4ecab27 100644 --- a/core/page/data_import_tool/data_import_tool.js +++ b/core/page/data_import_tool/data_import_tool.js @@ -10,7 +10,7 @@ wn.pages['data-import-tool'].onload = function(wrapper) {

\

\ - \ + \ Download with data\

\

\ @@ -141,12 +141,14 @@ wn.pages['data-import-tool'].onload = function(wrapper) { }); // add overwrite option - $(' Overwrite\ + $('\ + Overwrite\

If you are uploading a child table (for example Item Price), the all the entries of that table will be deleted (for that parent record) and new entries will be made.


') .insertBefore('#dit-upload-area form input[type="submit"]') // add ignore option - $(' Ignore Encoding Errors

') + $('\ + Ignore Encoding Errors

') .insertBefore('#dit-upload-area form input[type="submit"]') // rename button diff --git a/public/js/legacy/utils/datatype.js b/public/js/legacy/utils/datatype.js index 533dd7ecdd..ea6d1c245b 100644 --- a/public/js/legacy/utils/datatype.js +++ b/public/js/legacy/utils/datatype.js @@ -94,7 +94,7 @@ function is_null(v) { } function set_value_in(ele, v, ftype, fopt, doc) { - $(ele).html(wn.format(v, {fieldtype:ftype, options:fopt}, doc)); + $(ele).html(wn.format(v, {fieldtype:ftype, options:fopt}, null, doc)); return; } var $s = set_value_in; // used in print formats diff --git a/public/js/legacy/webpage/search.js b/public/js/legacy/webpage/search.js index 14181570b9..6434d0192d 100644 --- a/public/js/legacy/webpage/search.js +++ b/public/js/legacy/webpage/search.js @@ -201,7 +201,7 @@ function makeselector() { var l = $a($a(div,'div'),'span','link_type'); l.innerHTML = r.values[i][0]; l.link_name = r.values[i][0]; - l.dt = r.coloptions[0]; + l.dt = r.coloptions && r.coloptions[0]; if(d.input) l.onclick = function() { setlinkvalue(this.link_name); } diff --git a/public/js/legacy/widgets/form/fields.js b/public/js/legacy/widgets/form/fields.js index fd4f824eb4..156ac7e3d8 100644 --- a/public/js/legacy/widgets/form/fields.js +++ b/public/js/legacy/widgets/form/fields.js @@ -128,7 +128,7 @@ Field.prototype.set_description = function(txt) { } } -Field.prototype.get_status = function() { +Field.prototype.get_status = function(explain) { // if used in filters if(this.in_filter) this.not_in_form = this.in_filter; @@ -150,16 +150,22 @@ Field.prototype.get_status = function() { else ret='None'; + if(explain) console.log("By Permission:" + ret) + // hidden if(cint(this.df.hidden)) { ret = 'None'; } + if(explain) console.log("By Hidden:" + ret) + // for submit if(ret=='Write' && cint(cur_frm.doc.docstatus) > 0) { ret = 'Read'; } + if(explain) console.log("By Submit:" + ret) + // allow on submit var a_o_s = cint(this.df.allow_on_submit); @@ -172,12 +178,16 @@ Field.prototype.get_status = function() { a_o_s = _f.cur_grid.field.df.allow_on_submit; } } + + if(explain) console.log("Allow on Submit:" + a_o_s) if(ret=="Read" && a_o_s && cint(cur_frm.doc.docstatus)==1 && cur_frm.perm[this.df.permlevel][WRITE]) { ret='Write'; } + if(explain) console.log("By Allow on Submt:" + ret) + // workflow state if(ret=="Write" && cur_frm && cur_frm.state_fieldname) { if(cint(cur_frm.read_only)) { @@ -189,13 +199,17 @@ Field.prototype.get_status = function() { ret = 'Read'; } } - + + if(explain) console.log("By Workflow:" + ret) + // make a field read_only if read_only // is checked (disregards write permission) if(ret=="Write" && cint(this.df.read_only)) { ret = "Read"; } + if(explain) console.log("By Read Only:" + ret) + return ret; } @@ -862,7 +876,7 @@ FloatField.prototype.onmake_input = function() { } } FloatField.prototype.set_disp = function(val) { - this.set_disp_html(wn.format(val, this.df, locals[this.doctype][this.name])); + this.set_disp_html(wn.format(val, this.df, null, locals[this.doctype][this.name])); } function PercentField() { } PercentField.prototype = new FloatField(); diff --git a/public/js/legacy/widgets/form/grid.js b/public/js/legacy/widgets/form/grid.js index 074628a8c3..c92a76ebb1 100644 --- a/public/js/legacy/widgets/form/grid.js +++ b/public/js/legacy/widgets/form/grid.js @@ -429,7 +429,8 @@ _f.Grid.prototype.notify_keypress = function(e, keycode) { } _f.Grid.prototype.make_template = function(hc) { - hc.template = make_field(wn.meta.get_docfield(hc.doctype, hc.fieldname), hc.doctype, '', this.field.frm, true); + hc.template = make_field(wn.meta.get_docfield(hc.doctype, hc.fieldname), hc.doctype, + '', this.field.frm, true); hc.template.grid = this; } diff --git a/public/js/wn/form/formatters.js b/public/js/wn/form/formatters.js index 604c8653be..e644bf06b5 100644 --- a/public/js/wn/form/formatters.js +++ b/public/js/wn/form/formatters.js @@ -19,7 +19,7 @@ wn.form.formatters = { Percent: function(value) { return cint(value) + "%"; }, - Currency: function(value, docfield, doc) { + Currency: function(value, docfield, options, doc) { var currency = wn.meta.get_field_currency(docfield, doc); return "
" + format_currency(value, currency) + "
"; }, @@ -95,7 +95,7 @@ wn.form.get_formatter = function(fieldtype) { return wn.form.formatters[fieldtype.replace(/ /g, "")] || wn.form.formatters.Data; } -wn.format = function(value, df, options) { +wn.format = function(value, df, options, doc) { if(!df) df = {"fieldtype":"Data"}; - return wn.form.get_formatter(df.fieldtype)(value, df, options); + return wn.form.get_formatter(df.fieldtype)(value, df, options, doc); } \ No newline at end of file diff --git a/public/js/wn/model/meta.js b/public/js/wn/model/meta.js index a758d37e18..a15da03437 100644 --- a/public/js/wn/model/meta.js +++ b/public/js/wn/model/meta.js @@ -116,6 +116,10 @@ $.extend(wn.meta, { var options = df.options.split(":"); if(options.length==3) { // get reference record e.g. Company + var docname = doc[options[1]]; + if(!docname) { + docname = cur_frm.doc[options[1]] + } currency = wn.model.get_value(options[0], doc[options[1]], options[2]) || currency; } diff --git a/public/js/wn/views/listview.js b/public/js/wn/views/listview.js index b886d88de6..5046b9a9fd 100644 --- a/public/js/wn/views/listview.js +++ b/public/js/wn/views/listview.js @@ -262,7 +262,7 @@ wn.views.ListView = Class.extend({ } else if(data[opts.content]) { $("") - .html(wn.format(data[opts.content], opts.df, data)) + .html(wn.format(data[opts.content], opts.df, null, data)) .appendTo(parent) } diff --git a/public/js/wn/views/moduleview.js b/public/js/wn/views/moduleview.js index 3a18d8cc49..cc48d1f4db 100644 --- a/public/js/wn/views/moduleview.js +++ b/public/js/wn/views/moduleview.js @@ -103,12 +103,14 @@ wn.views.moduleview.ModuleView = Class.extend({ // doctype permissions if(item.doctype && !wn.model.can_read(item.doctype)) { - item.link = item.label; + //item.link = item.label; + return; } // page permissions if(item.page && !in_list(wn.boot.allowed_pages, item.page)) { - item.link = item.label; + //item.link = item.label; + return; } if((item.country && wn.boot.control_panel.country==item.country) diff --git a/public/js/wn/views/reportview.js b/public/js/wn/views/reportview.js index 941127ae85..c70e722b21 100644 --- a/public/js/wn/views/reportview.js +++ b/public/js/wn/views/reportview.js @@ -183,7 +183,7 @@ wn.views.ReportView = wn.ui.Listing.extend({ width: (docfield ? cint(docfield.width) : 120) || 120, formatter: function(row, cell, value, columnDef, dataContext) { var docfield = columnDef.docfield; - return wn.format(value, docfield, dataContext); + return wn.format(value, docfield, null, dataContext); } } return coldef; diff --git a/webnotes/db.py b/webnotes/db.py index 8774afd572..6aeefc6a02 100644 --- a/webnotes/db.py +++ b/webnotes/db.py @@ -126,6 +126,9 @@ class Database: else: return self._cursor.fetchall() + def sql_list(self, query, values=()): + return [r[0] for r in self.sql(query, values)] + def check_transaction_status(self, query): if self.in_transaction and query and query.strip().split()[0].lower() in ['start', 'alter', 'drop', 'create']: raise Exception, 'This statement can cause implicit commit' diff --git a/webnotes/model/db_schema.py b/webnotes/model/db_schema.py index 97d40252ec..7ee9ef6497 100644 --- a/webnotes/model/db_schema.py +++ b/webnotes/model/db_schema.py @@ -34,7 +34,7 @@ type_map = { 'currency': ('decimal', '18,6') ,'int': ('int', '11') ,'float': ('decimal', '18,6') - ,'percent': ('decimal', '9,6') + ,'percent': ('decimal', '18,6') ,'check': ('int', '1') ,'small text': ('text', '') ,'long text': ('longtext', '') @@ -264,10 +264,19 @@ class DbColumn: self.table.add_index.append(self) # default - if (self.default and (current_def['default'] != self.default) and (self.default not in default_shortcuts) and not (column_def in ['text','blob'])): + if (self.default and self.default_changed(current_def) and (self.default not in default_shortcuts) and not (column_def in ['text','blob'])): self.table.set_default.append(self) + def default_changed(self, current_def): + if "decimal" in current_def['type']: + try: + return float(current_def['default'])!=float(self.default) + except TypeError, e: + return True + else: + return current_def['default'] != self.default + class DbManager: """ Basically, a wrapper for oft-used mysql commands. like show tables,databases, variables etc... diff --git a/webnotes/widgets/search.py b/webnotes/widgets/search.py index ae2ccc2da1..0f3947ea86 100644 --- a/webnotes/widgets/search.py +++ b/webnotes/widgets/search.py @@ -23,6 +23,9 @@ # Search from __future__ import unicode_literals import webnotes +import webnotes.widgets.query_builder +from webnotes.utils import cstr +from startup.query_handlers import standard_queries # this is called when a new doctype is setup for search - to set the filters @webnotes.whitelist() @@ -49,6 +52,30 @@ def getsearchfields(): webnotes.response['searchfields'] = [['name', 'ID', 'Data', '']] + res +# this is called by the Link Field +@webnotes.whitelist() +def search_link(dt, txt, query=None): + search_widget(dt, txt, query, page_len=10) + webnotes.response['results'] = build_for_autosuggest(webnotes.response["values"]) + +# this is called by the search box +@webnotes.whitelist() +def search_widget(doctype, txt, query=None, searchfield="name", start=0, page_len=50): + if query and query.split()[0].lower()!="select": + webnotes.response["values"] = webnotes.get_method(query)(doctype, txt, + searchfield, start, page_len) + elif not query and doctype in standard_queries: + search_widget(doctype, txt, standard_queries[doctype], searchfield, start, page_len) + else: + if query: + webnotes.response["values"] = webnotes.conn.sql(scrub_custom_query(query, + searchfield, txt)) + else: + query = make_query(', '.join(get_std_fields_list(doctype, searchfield)), doctype, + searchfield, txt, start, page_len) + + webnotes.widgets.query_builder.runquery(query) + def make_query(fields, dt, key, txt, start, length): doctype = webnotes.get_doctype(dt) @@ -86,10 +113,7 @@ def get_std_fields_list(dt, key): return ['`tab%s`.`%s`' % (dt, f.strip()) for f in sflist] def build_for_autosuggest(res): - from webnotes.utils import cstr - results = [] - for r in res: info = '' if len(r) > 1: @@ -105,39 +129,4 @@ def scrub_custom_query(query, key, txt): query = query.replace('%(key)s', key) if '%s' in query: query = query.replace('%s', ((txt or '') + '%')) - return query - -# this is called by the Link Field -@webnotes.whitelist() -def search_link(): - import webnotes.widgets.query_builder - - txt = webnotes.form_dict.get('txt') - dt = webnotes.form_dict.get('dt') - query = webnotes.form_dict.get('query') - - if query: - res = webnotes.conn.sql(scrub_custom_query(query, 'name', txt)) - else: - q = make_query(', '.join(get_std_fields_list(dt, 'name')), dt, 'name', txt, '0', '10') - res = webnotes.widgets.query_builder.runquery(q, ret=1) - - # make output - webnotes.response['results'] = build_for_autosuggest(res) - -# this is called by the search box -@webnotes.whitelist() -def search_widget(): - import webnotes.widgets.query_builder - - dt = webnotes.form_dict.get('doctype') - txt = webnotes.form_dict.get('txt') or '' - key = webnotes.form_dict.get('searchfield') or 'name' # key field - user_query = webnotes.form_dict.get('query') or '' - - if user_query: - query = scrub_custom_query(user_query, key, txt) - else: - query = make_query(', '.join(get_std_fields_list(dt, key)), dt, key, txt, webnotes.form_dict.get('start') or 0, webnotes.form_dict.get('page_len') or 50) - - webnotes.widgets.query_builder.runquery(query) + return query \ No newline at end of file