From 348db9c49bb90d39c5eb36f5710043a44350124c Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 6 Aug 2013 17:53:40 +0530 Subject: [PATCH] [salary structure] Cleanup, Fixed Monthly Register Report and other minor changes --- core/page/data_import_tool/data_import_tool.py | 12 ++++++------ public/js/wn/form/control.js | 2 +- public/js/wn/form/grid.js | 17 +++++++++++------ webnotes/widgets/query_report.py | 6 +++--- webnotes/widgets/reportview.py | 5 +++-- wnf.py | 7 +++++++ 6 files changed, 31 insertions(+), 18 deletions(-) diff --git a/core/page/data_import_tool/data_import_tool.py b/core/page/data_import_tool/data_import_tool.py index cfbbbe787c..76e4bd5d4d 100644 --- a/core/page/data_import_tool/data_import_tool.py +++ b/core/page/data_import_tool/data_import_tool.py @@ -43,11 +43,11 @@ def get_template(): if all_doctypes: doctype_parentfield = {} - doctypes = [] + child_doctypes = [] for d in get_table_fields(doctype): - doctypes.append(d[0]) + child_doctypes.append(d[0]) doctype_parentfield[d[0]] = d[1] - + def add_main_header(): w.writerow(['Data Import Template']) w.writerow([data_keys.main_table, doctype]) @@ -187,9 +187,9 @@ def get_template(): if all_doctypes: # add child tables - for child_doctype in doctypes[1:]: + for child_doctype in child_doctypes: for ci, child in enumerate(webnotes.conn.sql("""select * from `tab%s` - where parent=%s""" % (child_doctype, "%s"), doc.name, as_dict=1)): + where parent=%s order by idx""" % (child_doctype, "%s"), doc.name, as_dict=1)): add_data_row(row_group, child_doctype, child, ci) for row in row_group: @@ -211,7 +211,7 @@ def get_template(): build_field_columns(doctype) if all_doctypes: - for d in doctypes[1:]: + for d in child_doctypes: append_empty_field_column() build_field_columns(d) diff --git a/public/js/wn/form/control.js b/public/js/wn/form/control.js index eb3103648e..0f6a177c82 100644 --- a/public/js/wn/form/control.js +++ b/public/js/wn/form/control.js @@ -29,7 +29,7 @@ wn.ui.form.Control = Class.extend({ // if developer_mode=1, show fieldname as tooltip if(wn.boot.profile && wn.boot.profile.name==="Administrator" && wn.boot.developer_mode===1 && this.$wrapper) { - this.$wrapper.tooltip({title: this.df.fieldname}); + this.$wrapper.attr("title", this.df.fieldname); } }, make: function() { diff --git a/public/js/wn/form/grid.js b/public/js/wn/form/grid.js index 84df3960f6..a08d5846f7 100644 --- a/public/js/wn/form/grid.js +++ b/public/js/wn/form/grid.js @@ -287,7 +287,7 @@ wn.ui.form.GridRow = Class.extend({ } // append button column - if(me.doc) { + if(me.doc && this.is_editable()) { if(!me.grid.$row_actions) { me.grid.$row_actions = $('
\ @@ -298,11 +298,13 @@ wn.ui.form.GridRow = Class.extend({
'); } $col = me.grid.$row_actions.clone().appendTo(me.row); - - $col.find(".grid-insert-row").click(function() { me.insert(); return false; }); - $col.find(".grid-delete-row").click(function() { me.remove(); return false; }); - this.toggle_add_delete_button_display($col); + if($col.width() < 50) { + $col.remove(); + } else { + $col.find(".grid-insert-row").click(function() { me.insert(); return false; }); + $col.find(".grid-delete-row").click(function() { me.remove(); return false; }); + } } $(this.frm.wrapper).trigger("grid-row-render", [this]); @@ -350,9 +352,12 @@ wn.ui.form.GridRow = Class.extend({ callback && callback(); }); }, + is_editable: function() { + return this.grid.display_status=="Write" && !this.grid.static_rows + }, toggle_add_delete_button_display: function($parent) { $parent.find(".grid-delete-row, .grid-insert-row") - .toggle(this.grid.display_status=="Write" && !this.grid.static_rows); + .toggle(this.is_editable()); }, render_form: function() { this.make_form(); diff --git a/webnotes/widgets/query_report.py b/webnotes/widgets/query_report.py index c3be9dd54b..d7c407551c 100644 --- a/webnotes/widgets/query_report.py +++ b/webnotes/widgets/query_report.py @@ -80,7 +80,7 @@ def get_filtered_data(ref_doctype, columns, data): linked_doctypes = get_linked_doctypes(columns) match_filters = get_user_match_filters(linked_doctypes, ref_doctype) - + if match_filters: matched_columns = get_matched_columns(linked_doctypes, match_filters) for row in data: @@ -122,8 +122,8 @@ def get_user_match_filters(doctypes, ref_doctype): webnotes.widgets.reportview.doctypes = doctypes_meta for dt in doctypes: - match_filters = webnotes.widgets.reportview.build_match_conditions(dt, - None, False, match_filters) + match_filters.update(webnotes.widgets.reportview.build_match_conditions(dt, + None, False)) return match_filters diff --git a/webnotes/widgets/reportview.py b/webnotes/widgets/reportview.py index 0a5c787d28..a2da8c0494 100644 --- a/webnotes/widgets/reportview.py +++ b/webnotes/widgets/reportview.py @@ -177,11 +177,11 @@ def build_filter_conditions(filters, conditions): conditions.append('ifnull(' + tname + '.' + f[1] + ",0) " + f[2] \ + " " + cstr(f[3])) -def build_match_conditions(doctype, fields=None, as_condition=True, match_filters=None): +def build_match_conditions(doctype, fields=None, as_condition=True): """add match conditions if applicable""" global tables, roles - if not match_filters: match_filters = {} + match_filters = {} match_conditions = [] match = True @@ -215,6 +215,7 @@ def build_match_conditions(doctype, fields=None, as_condition=True, match_filter # don't restrict if another read permission at level 0 # exists without a match restriction match = False + match_filters = {} if as_condition: if match_conditions and match: diff --git a/wnf.py b/wnf.py index 5f5c4e1602..e0d945aabc 100755 --- a/wnf.py +++ b/wnf.py @@ -139,6 +139,9 @@ def setup_options(): parser.add_option('--install_fresh', nargs=1, metavar = "NEW_DB_NAME", help="install fresh db") + parser.add_option('--make_demo', default=False, action="store_true", + help="install in database 'demo'") + # update parser.add_option("-u", "--update", help="Pull, run latest patches and sync all", @@ -391,6 +394,10 @@ def run(): inst = Installer('root') inst.import_from_db(options.install_fresh, verbose = 1) + elif options.make_demo: + import utilities.make_demo + utilities.make_demo.make() + elif options.diff_ref_file is not None: import webnotes.modules.diff webnotes.modules.diff.diff_ref_file()