Browse Source

[salary structure] Cleanup, Fixed Monthly Register Report and other minor changes

version-14
Rushabh Mehta 12 years ago
parent
commit
348db9c49b
6 changed files with 31 additions and 18 deletions
  1. +6
    -6
      core/page/data_import_tool/data_import_tool.py
  2. +1
    -1
      public/js/wn/form/control.js
  3. +11
    -6
      public/js/wn/form/grid.js
  4. +3
    -3
      webnotes/widgets/query_report.py
  5. +3
    -2
      webnotes/widgets/reportview.py
  6. +7
    -0
      wnf.py

+ 6
- 6
core/page/data_import_tool/data_import_tool.py View File

@@ -43,11 +43,11 @@ def get_template():
if all_doctypes: if all_doctypes:
doctype_parentfield = {} doctype_parentfield = {}
doctypes = []
child_doctypes = []
for d in get_table_fields(doctype): for d in get_table_fields(doctype):
doctypes.append(d[0])
child_doctypes.append(d[0])
doctype_parentfield[d[0]] = d[1] doctype_parentfield[d[0]] = d[1]
def add_main_header(): def add_main_header():
w.writerow(['Data Import Template']) w.writerow(['Data Import Template'])
w.writerow([data_keys.main_table, doctype]) w.writerow([data_keys.main_table, doctype])
@@ -187,9 +187,9 @@ def get_template():
if all_doctypes: if all_doctypes:
# add child tables # 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` 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) add_data_row(row_group, child_doctype, child, ci)
for row in row_group: for row in row_group:
@@ -211,7 +211,7 @@ def get_template():


build_field_columns(doctype) build_field_columns(doctype)
if all_doctypes: if all_doctypes:
for d in doctypes[1:]:
for d in child_doctypes:
append_empty_field_column() append_empty_field_column()
build_field_columns(d) build_field_columns(d)


+ 1
- 1
public/js/wn/form/control.js View File

@@ -29,7 +29,7 @@ wn.ui.form.Control = Class.extend({
// if developer_mode=1, show fieldname as tooltip // if developer_mode=1, show fieldname as tooltip
if(wn.boot.profile && wn.boot.profile.name==="Administrator" && if(wn.boot.profile && wn.boot.profile.name==="Administrator" &&
wn.boot.developer_mode===1 && this.$wrapper) { wn.boot.developer_mode===1 && this.$wrapper) {
this.$wrapper.tooltip({title: this.df.fieldname});
this.$wrapper.attr("title", this.df.fieldname);
} }
}, },
make: function() { make: function() {


+ 11
- 6
public/js/wn/form/grid.js View File

@@ -287,7 +287,7 @@ wn.ui.form.GridRow = Class.extend({
} }
// append button column // append button column
if(me.doc) {
if(me.doc && this.is_editable()) {
if(!me.grid.$row_actions) { if(!me.grid.$row_actions) {
me.grid.$row_actions = $('<div class="col col-lg-1" \ me.grid.$row_actions = $('<div class="col col-lg-1" \
style="text-align: right; padding-right: 5px;">\ style="text-align: right; padding-right: 5px;">\
@@ -298,11 +298,13 @@ wn.ui.form.GridRow = Class.extend({
</div>'); </div>');
} }
$col = me.grid.$row_actions.clone().appendTo(me.row); $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]); $(this.frm.wrapper).trigger("grid-row-render", [this]);
@@ -350,9 +352,12 @@ wn.ui.form.GridRow = Class.extend({
callback && callback(); callback && callback();
}); });
}, },
is_editable: function() {
return this.grid.display_status=="Write" && !this.grid.static_rows
},
toggle_add_delete_button_display: function($parent) { toggle_add_delete_button_display: function($parent) {
$parent.find(".grid-delete-row, .grid-insert-row") $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() { render_form: function() {
this.make_form(); this.make_form();


+ 3
- 3
webnotes/widgets/query_report.py View File

@@ -80,7 +80,7 @@ def get_filtered_data(ref_doctype, columns, data):


linked_doctypes = get_linked_doctypes(columns) linked_doctypes = get_linked_doctypes(columns)
match_filters = get_user_match_filters(linked_doctypes, ref_doctype) match_filters = get_user_match_filters(linked_doctypes, ref_doctype)
if match_filters: if match_filters:
matched_columns = get_matched_columns(linked_doctypes, match_filters) matched_columns = get_matched_columns(linked_doctypes, match_filters)
for row in data: for row in data:
@@ -122,8 +122,8 @@ def get_user_match_filters(doctypes, ref_doctype):
webnotes.widgets.reportview.doctypes = doctypes_meta webnotes.widgets.reportview.doctypes = doctypes_meta


for dt in doctypes: 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 return match_filters




+ 3
- 2
webnotes/widgets/reportview.py View File

@@ -177,11 +177,11 @@ def build_filter_conditions(filters, conditions):
conditions.append('ifnull(' + tname + '.' + f[1] + ",0) " + f[2] \ conditions.append('ifnull(' + tname + '.' + f[1] + ",0) " + f[2] \
+ " " + cstr(f[3])) + " " + 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""" """add match conditions if applicable"""
global tables, roles global tables, roles
if not match_filters: match_filters = {}
match_filters = {}
match_conditions = [] match_conditions = []
match = True 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 # don't restrict if another read permission at level 0
# exists without a match restriction # exists without a match restriction
match = False match = False
match_filters = {}
if as_condition: if as_condition:
if match_conditions and match: if match_conditions and match:


+ 7
- 0
wnf.py View File

@@ -139,6 +139,9 @@ def setup_options():
parser.add_option('--install_fresh', nargs=1, metavar = "NEW_DB_NAME", parser.add_option('--install_fresh', nargs=1, metavar = "NEW_DB_NAME",
help="install fresh db") help="install fresh db")


parser.add_option('--make_demo', default=False, action="store_true",
help="install in database 'demo'")

# update # update
parser.add_option("-u", "--update", parser.add_option("-u", "--update",
help="Pull, run latest patches and sync all", help="Pull, run latest patches and sync all",
@@ -391,6 +394,10 @@ def run():
inst = Installer('root') inst = Installer('root')
inst.import_from_db(options.install_fresh, verbose = 1) 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: elif options.diff_ref_file is not None:
import webnotes.modules.diff import webnotes.modules.diff
webnotes.modules.diff.diff_ref_file() webnotes.modules.diff.diff_ref_file()


Loading…
Cancel
Save