From e487b1a37d82cbe0aa72c235fafa751eb15f195e Mon Sep 17 00:00:00 2001 From: Saurabh Date: Tue, 9 Jul 2013 10:10:43 +0530 Subject: [PATCH 01/13] changes to handle server side queries --- webnotes/widgets/reportview.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/webnotes/widgets/reportview.py b/webnotes/widgets/reportview.py index 8b35e0d6b0..e99d6d3972 100644 --- a/webnotes/widgets/reportview.py +++ b/webnotes/widgets/reportview.py @@ -172,6 +172,8 @@ def build_conditions(doctype, fields, filters, docstatus): def build_filter_conditions(filters, conditions): """build conditions from user filters""" from webnotes.utils import cstr + global tables + if not tables: tables = [] for f in filters: tname = ('`tab' + f[0] + '`') @@ -179,7 +181,7 @@ def build_filter_conditions(filters, conditions): tables.append(tname) # prepare in condition - if f[2]=='in': + if f[2] in ['in', 'not in']: opts = ["'" + t.strip().replace("'", "\\'") + "'" for t in f[3].split(',')] f[3] = "(" + ', '.join(opts) + ")" conditions.append(tname + '.' + f[1] + " " + f[2] + " " + f[3]) From f69207e243f0753b9b493d21a400afd8fdbd8079 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Tue, 9 Jul 2013 16:19:49 +0530 Subject: [PATCH 02/13] [get_query]to server side --- core/doctype/communication/communication.js | 23 +++++++++---------- core/doctype/communication/communication.py | 20 ++++++++++++++++ core/doctype/custom_field/custom_field.js | 14 +++++++---- core/doctype/customize_form/customize_form.js | 22 ++++++++++++------ 4 files changed, 56 insertions(+), 23 deletions(-) diff --git a/core/doctype/communication/communication.js b/core/doctype/communication/communication.js index 640b2ad902..f418333a87 100644 --- a/core/doctype/communication/communication.js +++ b/core/doctype/communication/communication.js @@ -1,22 +1,21 @@ cur_frm.cscript.onload = function(doc) { cur_frm.fields_dict.user.get_query = function() { - return "select name, concat_ws(' ', first_name, middle_name, last_name) \ - from `tabProfile` where ifnull(enabled, 0)=1 and docstatus < 2 and \ - (%(key)s like \"%s\" or \ - concat_ws(' ', first_name, middle_name, last_name) like \"%%%s\") \ - limit 50"; + return { + query: "core.doctype.communication.communication.get_user" + } }; cur_frm.fields_dict.lead.get_query = function() { - return "select name, lead_name from `tabLead` \ - where docstatus < 2 and \ - (%(key)s like \"%s\" or lead_name like \"%%%s\" or \ - company_name like \"%%%s\") \ - order by lead_name asc limit 50"; + return { + query: "core.doctype.communication.communication.get_user" + } }; - cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query; - cur_frm.fields_dict.supplier.get_query = erpnext.utils.supplier_query; + cur_frm.fields_dict.customer.get_query = function(doc,cdt,cdn) { + return{ query:"controllers.queries.customer_query" } } + + cur_frm.fields_dict.supplier.get_query = function(doc,cdt,cdn) { + return{ query:"controllers.queries.supplier_query" } } if(doc.content) doc.content = wn.utils.escape_script_and_style(doc.content); diff --git a/core/doctype/communication/communication.py b/core/doctype/communication/communication.py index c24330bbb7..ff4b050f2e 100644 --- a/core/doctype/communication/communication.py +++ b/core/doctype/communication/communication.py @@ -119,3 +119,23 @@ class DocType(): def __init__(self, doc, doclist=[]): self.doc = doc self.doclist = doclist + +def get_user(doctype, txt, searchfield, start, page_len, filters): + from controllers.queries import get_match_cond + return webnotes.conn.sql("""select name, concat_ws(' ', first_name, middle_name, last_name) + from `tabProfile` where ifnull(enabled, 0)=1 and docstatus < 2 and + (%(key)s like "%(txt)s" or concat_ws(' ', first_name, middle_name, last_name) + like "%(txt)s") + %(mcond)s limit %(start)s, %(page_len)s """ % {'key': searchfield, + 'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype, searchfield), + 'start': start, 'page_len': page_len}) + +def get_lead(doctype, txt, searchfield, start, page_len, filters): + from controllers.queries import get_match_cond + return webnotes.conn.sql(""" select name, lead_name from `tabLead` + where docstatus < 2 and (%(key)s like "%(txt)s" + or lead_name like "%(txt)s" or company_name like "%(txt)s") + %(mcond)s order by lead_name asc limit %(start)s, %(page_len)s + """ % {'key': searchfield,'txt': "%%%s%%" % txt, + 'mcond':get_match_cond(doctype, searchfield), 'start': start, + 'page_len': page_len}) \ No newline at end of file diff --git a/core/doctype/custom_field/custom_field.js b/core/doctype/custom_field/custom_field.js index e122339fcb..ee02ae8549 100644 --- a/core/doctype/custom_field/custom_field.js +++ b/core/doctype/custom_field/custom_field.js @@ -55,10 +55,16 @@ cur_frm.cscript.label = function(doc){ cur_frm.fields_dict['dt'].get_query = function(doc, dt, dn) { - return 'SELECT name FROM `tabDocType` \ - WHERE IFNULL(issingle,0)=0 AND \ - module != "Core" AND \ - name LIKE "%s%%" ORDER BY name ASC LIMIT 50'; + return{ + filters:[ + ['DocType', 'issingle', '=', 0], + ['DocType', 'module', '!=', 'Core'] + ] + } + // return 'SELECT name FROM `tabDocType` \ + // WHERE IFNULL(issingle,0)=0 AND \ + // module != "Core" AND \ + // name LIKE "%s%%" ORDER BY name ASC LIMIT 50'; } cur_frm.cscript.fieldtype = function(doc, dt, dn) { diff --git a/core/doctype/customize_form/customize_form.js b/core/doctype/customize_form/customize_form.js index ac60263552..a1db4a0ae3 100644 --- a/core/doctype/customize_form/customize_form.js +++ b/core/doctype/customize_form/customize_form.js @@ -36,13 +36,21 @@ cur_frm.cscript.onload = function(doc, dt, dn) { } cur_frm.fields_dict.doc_type.get_query = function(doc, dt, dn) { - return 'SELECT name FROM `tabDocType` \ - WHERE ((IFNULL(issingle,0)=0 AND \ - IFNULL(in_create, 0)=0 AND \ - name not in ("DocType", "DocField", "DocPerm", "Profile", "Role", "UserRole", "Page", \ - "Page Role", "Module Def", "Print Format", "Report")) \ - or name = "Item Group") \ - AND name LIKE "%s%%" ORDER BY name ASC LIMIT 50'; + return{ + filters:[ + ['DocType', 'issingle', '=', 0], + ['DocType', 'in_create', '=', 0], + ['DocType', 'name', 'not in', 'DocType, DocField, DocPerm, Profile, Role, UserRole,\ + Page, Page Role, Module Def, Print Format, Report'] + ] + } + // return 'SELECT name FROM `tabDocType` \ + // WHERE ((IFNULL(issingle,0)=0 AND \ + // IFNULL(in_create, 0)=0 AND \ + // name not in ("DocType", "DocField", "DocPerm", "Profile", "Role", "UserRole", "Page", \ + // "Page Role", "Module Def", "Print Format", "Report")) \ + // or name = "Item Group") \ + // AND name LIKE "%s%%" ORDER BY name ASC LIMIT 50'; } cur_frm.cscript.refresh = function(doc, dt, dn) { From 8f7dbbd2f28dcae15a62577247e206fc56f45339 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Tue, 9 Jul 2013 18:21:36 +0530 Subject: [PATCH 03/13] [get_query]to server side --- core/doctype/custom_field/custom_field.js | 4 ---- core/doctype/customize_form/customize_form.js | 7 ------- 2 files changed, 11 deletions(-) diff --git a/core/doctype/custom_field/custom_field.js b/core/doctype/custom_field/custom_field.js index ee02ae8549..e27a4480ce 100644 --- a/core/doctype/custom_field/custom_field.js +++ b/core/doctype/custom_field/custom_field.js @@ -61,10 +61,6 @@ cur_frm.fields_dict['dt'].get_query = function(doc, dt, dn) { ['DocType', 'module', '!=', 'Core'] ] } - // return 'SELECT name FROM `tabDocType` \ - // WHERE IFNULL(issingle,0)=0 AND \ - // module != "Core" AND \ - // name LIKE "%s%%" ORDER BY name ASC LIMIT 50'; } cur_frm.cscript.fieldtype = function(doc, dt, dn) { diff --git a/core/doctype/customize_form/customize_form.js b/core/doctype/customize_form/customize_form.js index ddfa1ef3c1..8ac191ee7b 100644 --- a/core/doctype/customize_form/customize_form.js +++ b/core/doctype/customize_form/customize_form.js @@ -50,13 +50,6 @@ cur_frm.fields_dict.doc_type.get_query = function(doc, dt, dn) { Page, Page Role, Module Def, Print Format, Report'] ] } - // return 'SELECT name FROM `tabDocType` \ - // WHERE ((IFNULL(issingle,0)=0 AND \ - // IFNULL(in_create, 0)=0 AND \ - // name not in ("DocType", "DocField", "DocPerm", "Profile", "Role", "UserRole", "Page", \ - // "Page Role", "Module Def", "Print Format", "Report")) \ - // or name = "Item Group") \ - // AND name LIKE "%s%%" ORDER BY name ASC LIMIT 50'; } cur_frm.cscript.refresh = function(doc, dt, dn) { From 446599e43e1d954c4ce9d8d18bf286a175aa296f Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 10 Jul 2013 12:06:58 +0530 Subject: [PATCH 04/13] [minor] [style] added section break to grid --- public/css/ui/common.css | 4 ++++ public/js/wn/form/grid.js | 11 +++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/public/css/ui/common.css b/public/css/ui/common.css index cbb0420798..e5d33e9792 100644 --- a/public/css/ui/common.css +++ b/public/css/ui/common.css @@ -395,6 +395,10 @@ textarea[data-fieldtype="Small Text"] { cursor: pointer; } +.grid-row .panel { + background-color: #fffff8; +} + /* form footer */ .form-footer { diff --git a/public/js/wn/form/grid.js b/public/js/wn/form/grid.js index bc89cc353e..2ef91971bd 100644 --- a/public/js/wn/form/grid.js +++ b/public/js/wn/form/grid.js @@ -323,11 +323,13 @@ wn.ui.form.GridRow = Class.extend({ render_form: function() { var me = this, make_row = function(label) { - var row = $('
').appendTo(me.form_area); - if(label) - $('

'+ label +'

') - .appendTo(row); + $('

'+ label +'


') + .appendTo(me.form_area); + + var row = $('
') + .css({"padding": "0px 15px"}) + .appendTo(me.form_area); var col1 = $('
').appendTo(row), col2 = $('
').appendTo(row); @@ -342,6 +344,7 @@ wn.ui.form.GridRow = Class.extend({ if(df.fieldtype=="Section Break") { cols = make_row(df.label); cnt = 0; + return; } var fieldwrapper = $('
') .appendTo(cols[cnt % 2]) From 5b254c079d0194edbcfccf12b74b6caac64ae413 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 10 Jul 2013 13:05:32 +0530 Subject: [PATCH 05/13] [minor] fix to has_permission --- webnotes/__init__.py | 11 +++++++---- webnotes/model/mapper.py | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/webnotes/__init__.py b/webnotes/__init__.py index e27c978257..64afdefd35 100644 --- a/webnotes/__init__.py +++ b/webnotes/__init__.py @@ -245,13 +245,16 @@ def get_roles(user=None, with_standard=True): return roles -def has_permission(doctype, ptype="read", doc=None): +def has_permission(doctype, ptype="read", refdoc=None): """check if user has permission""" from webnotes.defaults import get_user_default_as_list if session.user=="Administrator": return True if conn.get_value("DocType", doctype, "istable"): return True + if isinstance(refdoc, basestring): + refdoc = doc(doctype, refdoc) + perms = conn.sql("""select `name`, `match` from tabDocPerm p where p.parent = %s and ifnull(p.`%s`,0) = 1 @@ -259,7 +262,7 @@ def has_permission(doctype, ptype="read", doc=None): and (p.role="All" or p.role in (select `role` from tabUserRole where `parent`=%s)) """ % ("%s", ptype, "%s"), (doctype, session.user), as_dict=1) - if doc: + if refdoc: match_failed = {} for p in perms: if p.match: @@ -268,11 +271,11 @@ def has_permission(doctype, ptype="read", doc=None): else: keys = [p.match, p.match] - if doc.fields.get(keys[0],"[No Value]") \ + if refdoc.fields.get(keys[0],"[No Value]") \ in get_user_default_as_list(keys[1]): return True else: - match_failed[keys[0]] = doc.fields.get(keys[0],"[No Value]") + match_failed[keys[0]] = refdoc.fields.get(keys[0],"[No Value]") else: # found a permission without a match return True diff --git a/webnotes/model/mapper.py b/webnotes/model/mapper.py index ddc0d8a2e3..b79289e65b 100644 --- a/webnotes/model/mapper.py +++ b/webnotes/model/mapper.py @@ -32,7 +32,7 @@ def get_mapped_doclist(from_doctype, from_docname, table_maps, target_doclist=[] source = webnotes.bean(from_doctype, from_docname) - if not webnotes.has_permission(from_doctype, doc=source.doc): + if not webnotes.has_permission(from_doctype, "read", source.doc): webnotes.msgprint("No Permission", raise_exception=webnotes.PermissionError) source_meta = webnotes.get_doctype(from_doctype) From bffe5fb2cf6d0c06f8ed1dcdbbaabaefe226ba34 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 10 Jul 2013 14:16:59 +0530 Subject: [PATCH 06/13] [fix][hr] pull salary structure in salary slip --- webnotes/model/mapper.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/webnotes/model/mapper.py b/webnotes/model/mapper.py index ddc0d8a2e3..ae9db6c3ce 100644 --- a/webnotes/model/mapper.py +++ b/webnotes/model/mapper.py @@ -37,10 +37,13 @@ def get_mapped_doclist(from_doctype, from_docname, table_maps, target_doclist=[] source_meta = webnotes.get_doctype(from_doctype) target_meta = webnotes.get_doctype(table_maps[from_doctype]["doctype"]) - + # main if target_doclist: - target_doc = webnotes.doc(target_doclist[0]) + if isinstance(target_doclist[0], dict): + target_doc = webnotes.doc(fielddata=target_doclist[0]) + else: + target_doc = target_doclist[0] else: target_doc = webnotes.new_doc(table_maps[from_doctype]["doctype"]) From 534cd2d9009c988e2c942424a601e28f05b33330 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 10 Jul 2013 15:03:32 +0530 Subject: [PATCH 07/13] [feature] [grid] Allow Grid viewable columns to be selected via 'In List View' --- .../customize_form_field.txt | 8 +++++++- .../default_home_page/default_home_page.txt | 3 ++- core/doctype/defaultvalue/defaultvalue.txt | 3 ++- core/doctype/docfield/docfield.txt | 8 +++++++- core/doctype/docperm/docperm.txt | 8 +++++++- core/doctype/event_role/event_role.txt | 3 ++- core/doctype/event_user/event_user.txt | 3 ++- core/doctype/page_role/page_role.txt | 3 ++- core/doctype/userrole/userrole.txt | 3 ++- .../workflow_document_state.txt | 3 ++- .../workflow_transition/workflow_transition.txt | 3 ++- public/js/wn/form/grid.js | 17 +++++++++++++++-- 12 files changed, 52 insertions(+), 13 deletions(-) diff --git a/core/doctype/customize_form_field/customize_form_field.txt b/core/doctype/customize_form_field/customize_form_field.txt index fe5ba58607..f378c9a0bc 100644 --- a/core/doctype/customize_form_field/customize_form_field.txt +++ b/core/doctype/customize_form_field/customize_form_field.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-22 01:27:32", "docstatus": 0, - "modified": "2013-03-07 07:03:19", + "modified": "2013-07-10 14:54:06", "modified_by": "Administrator", "owner": "Administrator" }, @@ -37,6 +37,7 @@ "fieldname": "label", "fieldtype": "Data", "hidden": 0, + "in_list_view": 1, "label": "Label", "oldfieldname": "label", "oldfieldtype": "Data", @@ -49,6 +50,7 @@ "fieldname": "fieldtype", "fieldtype": "Select", "hidden": 0, + "in_list_view": 1, "label": "Type", "oldfieldname": "fieldtype", "oldfieldtype": "Select", @@ -62,6 +64,7 @@ "fieldname": "fieldname", "fieldtype": "Data", "hidden": 0, + "in_list_view": 1, "label": "Name", "oldfieldname": "fieldname", "oldfieldtype": "Data", @@ -76,6 +79,7 @@ "fieldname": "options", "fieldtype": "Text", "hidden": 0, + "in_list_view": 1, "label": "Options", "oldfieldname": "options", "oldfieldtype": "Text", @@ -89,6 +93,7 @@ "fieldname": "permlevel", "fieldtype": "Int", "hidden": 0, + "in_list_view": 1, "label": "Perm Level", "oldfieldname": "permlevel", "oldfieldtype": "Int", @@ -101,6 +106,7 @@ "fieldname": "width", "fieldtype": "Data", "hidden": 0, + "in_list_view": 1, "label": "Width", "oldfieldname": "width", "oldfieldtype": "Data", diff --git a/core/doctype/default_home_page/default_home_page.txt b/core/doctype/default_home_page/default_home_page.txt index 9a04bf3bb1..e605380f64 100644 --- a/core/doctype/default_home_page/default_home_page.txt +++ b/core/doctype/default_home_page/default_home_page.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-22 01:27:32", "docstatus": 0, - "modified": "2013-03-07 07:03:20", + "modified": "2013-07-10 14:54:07", "modified_by": "Administrator", "owner": "Administrator" }, @@ -15,6 +15,7 @@ { "doctype": "DocField", "fieldtype": "Link", + "in_list_view": 1, "name": "__common__", "oldfieldtype": "Link", "parent": "Default Home Page", diff --git a/core/doctype/defaultvalue/defaultvalue.txt b/core/doctype/defaultvalue/defaultvalue.txt index a560680b08..3b2fa1c101 100644 --- a/core/doctype/defaultvalue/defaultvalue.txt +++ b/core/doctype/defaultvalue/defaultvalue.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-22 01:27:32", "docstatus": 0, - "modified": "2013-03-07 07:03:20", + "modified": "2013-07-10 14:54:07", "modified_by": "Administrator", "owner": "Administrator" }, @@ -23,6 +23,7 @@ { "doctype": "DocField", "hidden": 0, + "in_list_view": 1, "name": "__common__", "parent": "DefaultValue", "parentfield": "fields", diff --git a/core/doctype/docfield/docfield.txt b/core/doctype/docfield/docfield.txt index 955891c30e..7362a518d7 100644 --- a/core/doctype/docfield/docfield.txt +++ b/core/doctype/docfield/docfield.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-22 01:27:33", "docstatus": 0, - "modified": "2013-07-03 10:03:56", + "modified": "2013-07-10 14:54:08", "modified_by": "Administrator", "owner": "Administrator" }, @@ -38,6 +38,7 @@ "fieldname": "label", "fieldtype": "Data", "hidden": 0, + "in_list_view": 1, "label": "Label", "oldfieldname": "label", "oldfieldtype": "Data", @@ -51,6 +52,7 @@ "fieldname": "fieldtype", "fieldtype": "Select", "hidden": 0, + "in_list_view": 1, "label": "Type", "oldfieldname": "fieldtype", "oldfieldtype": "Select", @@ -63,6 +65,7 @@ "fieldname": "fieldname", "fieldtype": "Data", "hidden": 0, + "in_list_view": 1, "label": "Name", "oldfieldname": "fieldname", "oldfieldtype": "Data", @@ -75,6 +78,7 @@ "fieldname": "options", "fieldtype": "Text", "hidden": 0, + "in_list_view": 1, "label": "Options", "oldfieldname": "options", "oldfieldtype": "Text", @@ -86,6 +90,7 @@ "fieldname": "reqd", "fieldtype": "Check", "hidden": 0, + "in_list_view": 1, "label": "Mandatory", "oldfieldname": "reqd", "oldfieldtype": "Check", @@ -98,6 +103,7 @@ "doctype": "DocField", "fieldname": "description", "fieldtype": "Text", + "in_list_view": 1, "label": "Description", "oldfieldname": "description", "oldfieldtype": "Text", diff --git a/core/doctype/docperm/docperm.txt b/core/doctype/docperm/docperm.txt index 4cfd1a1868..b620a5f9fd 100644 --- a/core/doctype/docperm/docperm.txt +++ b/core/doctype/docperm/docperm.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-22 01:27:33", "docstatus": 0, - "modified": "2013-03-07 07:03:20", + "modified": "2013-07-10 14:54:08", "modified_by": "Administrator", "owner": "Administrator" }, @@ -38,6 +38,7 @@ "fieldname": "permlevel", "fieldtype": "Int", "hidden": 0, + "in_list_view": 1, "label": "Level", "oldfieldname": "permlevel", "oldfieldtype": "Int", @@ -51,6 +52,7 @@ "fieldname": "role", "fieldtype": "Link", "hidden": 0, + "in_list_view": 1, "label": "Role", "oldfieldname": "role", "oldfieldtype": "Link", @@ -65,6 +67,7 @@ "fieldname": "read", "fieldtype": "Check", "hidden": 0, + "in_list_view": 1, "label": "Read", "oldfieldname": "read", "oldfieldtype": "Check", @@ -78,6 +81,7 @@ "fieldname": "write", "fieldtype": "Check", "hidden": 0, + "in_list_view": 1, "label": "Write", "oldfieldname": "write", "oldfieldtype": "Check", @@ -91,6 +95,7 @@ "fieldname": "create", "fieldtype": "Check", "hidden": 0, + "in_list_view": 1, "label": "Create", "oldfieldname": "create", "oldfieldtype": "Check", @@ -104,6 +109,7 @@ "fieldname": "submit", "fieldtype": "Check", "hidden": 0, + "in_list_view": 1, "label": "Submit", "oldfieldname": "submit", "oldfieldtype": "Check", diff --git a/core/doctype/event_role/event_role.txt b/core/doctype/event_role/event_role.txt index 02ff65ec42..72a223c6d8 100644 --- a/core/doctype/event_role/event_role.txt +++ b/core/doctype/event_role/event_role.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-22 01:27:33", "docstatus": 0, - "modified": "2013-03-07 07:03:21", + "modified": "2013-07-10 14:54:08", "modified_by": "Administrator", "owner": "Administrator" }, @@ -17,6 +17,7 @@ "doctype": "DocField", "fieldname": "role", "fieldtype": "Link", + "in_list_view": 1, "label": "Role", "name": "__common__", "oldfieldname": "role", diff --git a/core/doctype/event_user/event_user.txt b/core/doctype/event_user/event_user.txt index 5868e4799a..b8cb8cd2f3 100644 --- a/core/doctype/event_user/event_user.txt +++ b/core/doctype/event_user/event_user.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-22 01:27:33", "docstatus": 0, - "modified": "2013-03-07 07:03:21", + "modified": "2013-07-10 14:54:08", "modified_by": "Administrator", "owner": "Administrator" }, @@ -17,6 +17,7 @@ "doctype": "DocField", "fieldname": "person", "fieldtype": "Select", + "in_list_view": 1, "label": "Person", "name": "__common__", "oldfieldname": "person", diff --git a/core/doctype/page_role/page_role.txt b/core/doctype/page_role/page_role.txt index c5d398ee33..e2ce117122 100644 --- a/core/doctype/page_role/page_role.txt +++ b/core/doctype/page_role/page_role.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-22 01:27:34", "docstatus": 0, - "modified": "2013-03-07 07:03:26", + "modified": "2013-07-10 14:54:11", "modified_by": "Administrator", "owner": "Administrator" }, @@ -25,6 +25,7 @@ "fieldname": "role", "fieldtype": "Link", "hidden": 0, + "in_list_view": 1, "label": "Role", "name": "__common__", "oldfieldname": "role", diff --git a/core/doctype/userrole/userrole.txt b/core/doctype/userrole/userrole.txt index 29e86c6157..847c7b304e 100644 --- a/core/doctype/userrole/userrole.txt +++ b/core/doctype/userrole/userrole.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-06 11:30:13", "docstatus": 0, - "modified": "2013-02-13 07:51:57", + "modified": "2013-07-10 14:54:25", "modified_by": "Administrator", "owner": "Administrator" }, @@ -25,6 +25,7 @@ "fieldname": "role", "fieldtype": "Link", "hidden": 0, + "in_list_view": 1, "label": "Role", "name": "__common__", "oldfieldname": "role", diff --git a/core/doctype/workflow_document_state/workflow_document_state.txt b/core/doctype/workflow_document_state/workflow_document_state.txt index 3a00586a3f..892eace626 100644 --- a/core/doctype/workflow_document_state/workflow_document_state.txt +++ b/core/doctype/workflow_document_state/workflow_document_state.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-22 01:27:36", "docstatus": 0, - "modified": "2013-03-07 07:03:34", + "modified": "2013-07-10 14:54:25", "modified_by": "Administrator", "owner": "Administrator" }, @@ -16,6 +16,7 @@ }, { "doctype": "DocField", + "in_list_view": 1, "name": "__common__", "parent": "Workflow Document State", "parentfield": "fields", diff --git a/core/doctype/workflow_transition/workflow_transition.txt b/core/doctype/workflow_transition/workflow_transition.txt index ff87efc3f7..0bb1096099 100644 --- a/core/doctype/workflow_transition/workflow_transition.txt +++ b/core/doctype/workflow_transition/workflow_transition.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-22 01:27:36", "docstatus": 0, - "modified": "2013-03-07 07:03:34", + "modified": "2013-07-10 14:54:25", "modified_by": "Administrator", "owner": "Administrator" }, @@ -16,6 +16,7 @@ { "doctype": "DocField", "fieldtype": "Link", + "in_list_view": 1, "name": "__common__", "parent": "Workflow Transition", "parentfield": "fields", diff --git a/public/js/wn/form/grid.js b/public/js/wn/form/grid.js index 2ef91971bd..14ed6cc937 100644 --- a/public/js/wn/form/grid.js +++ b/public/js/wn/form/grid.js @@ -174,6 +174,12 @@ wn.ui.form.GridRow = Class.extend({
\
\
\ + \
\
\ ') @@ -203,7 +209,12 @@ wn.ui.form.GridRow = Class.extend({ }, set_button_events: function() { var me = this; - + + this.wrapper.find(".btn-success").click(function() { + me.toggle_view(); + return false; + }); + this.wrapper.find(".btn-danger").click(function() { me.wrapper.fadeOut(function() { wn.model.clear_doc(me.doc.doctype, me.doc.name); @@ -241,7 +252,7 @@ wn.ui.form.GridRow = Class.extend({ col = $('
' + (me.doc ? me.doc.idx : "#")+ '
') .appendTo(me.row) $.each(me.docfields, function(ci, df) { - if(!df.hidden && !df.print_hide && me.grid.frm.perm[df.permlevel][READ] + if(!df.hidden && df.in_list_view && me.grid.frm.perm[df.permlevel][READ] && !in_list(["Section Break", "Column Break"], df.fieldtype)) { var colsize = 2, txt = me.doc ? @@ -370,6 +381,8 @@ wn.ui.form.GridRow = Class.extend({ this.wrapper.find(".btn-danger, .grid-insert-row").toggle(false); } + this.wrapper.find(".footer-toolbar").toggle(me.fields.length > 6); + this.grid.open_grid_row = this; }, set_data: function() { From b18648252a8e0e61ba4b8534a26c9485fc7a8ef4 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 10 Jul 2013 16:02:41 +0530 Subject: [PATCH 08/13] [minor] [fix] Fix reverse tabbing in forms (when Shift key is pressed) --- public/js/wn/form/layout.js | 53 ++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/public/js/wn/form/layout.js b/public/js/wn/form/layout.js index 14e227a2e6..20bddf5966 100644 --- a/public/js/wn/form/layout.js +++ b/public/js/wn/form/layout.js @@ -131,14 +131,14 @@ wn.ui.form.Layout = Class.extend({ doctype = current.attr("data-doctype"), fieldname = current.attr("data-fieldname"); if(doctype) - return me.handle_tab(doctype, fieldname); + return me.handle_tab(doctype, fieldname, ev.shiftKey); } }) }, - handle_tab: function(doctype, fieldname) { + handle_tab: function(doctype, fieldname, shift) { var me = this, grid_row = null; - next = null, + prev = null, fields = me.frm.fields, in_grid = false; @@ -150,6 +150,14 @@ wn.ui.form.Layout = Class.extend({ for(var i=0, len=fields.length; i < len; i++) { if(fields[i].df.fieldname==fieldname) { + if(shift) { + if(prev) { + this.set_focus(prev) + } else { + $(cur_frm.wrapper).find(".btn-primary").focus(); + } + break; + } if(i==len-1) { // last field in this group if(grid_row) { @@ -164,7 +172,7 @@ wn.ui.form.Layout = Class.extend({ grid_row.grid.grid_rows[grid_row.doc.idx].toggle_view(true); } } else { - // last field - to title buttons + $(cur_frm.wrapper).find(".btn-primary").focus(); } } else { me.focus_on_next_field(i, fields); @@ -172,33 +180,36 @@ wn.ui.form.Layout = Class.extend({ break; } + if(fields[i].disp_status==="Write") + prev = fields[i]; } return false; }, focus_on_next_field: function(start_idx, fields) { // loop to find next eligible fields for(var ii= start_idx + 1, len = fields.length; ii < len; ii++) { - if(fields[ii].disp_status=="Write") { - var next = fields[ii]; - - // next is table, show the table - if(next.df.fieldtype=="Table") { - if(!next.grid.grid_rows.length) { - next.grid.add_new_row(1); - } else { - next.grid.grid_rows[0].toggle_view(true); - } - } - else if(next.editor) { - next.editor.set_focus(); - } - else if(next.$input) { - next.$input.focus(); - } + if(fields[ii].disp_status==="Write") { + this.set_focus(fields[ii]); break; } } }, + set_focus: function(field) { + // next is table, show the table + if(field.df.fieldtype=="Table") { + if(!field.grid.grid_rows.length) { + field.grid.add_new_row(1); + } else { + field.grid.grid_rows[0].toggle_view(true); + } + } + else if(field.editor) { + field.editor.set_focus(); + } + else if(field.$input) { + field.$input.focus(); + } + }, get_open_grid_row: function() { return $(".grid-row-open").data("grid_row"); }, From 7b1c78dbdbbad97ee55bed0b120ba9bd96fa8ab6 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 10 Jul 2013 16:48:29 +0530 Subject: [PATCH 09/13] [fix] related to mapping --- webnotes/model/mapper.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/webnotes/model/mapper.py b/webnotes/model/mapper.py index 5c265b597d..6238432edf 100644 --- a/webnotes/model/mapper.py +++ b/webnotes/model/mapper.py @@ -101,10 +101,19 @@ def map_doc(source_doc, target_doc, table_map, source_meta, target_meta, source_ # map other fields - for source_key, target_key in table_map.get("field_map", {}).items(): - val = source_doc.fields.get(source_key) - if val not in (None, ""): - target_doc.fields[target_key] = val + field_map = table_map.get("field_map") + + if field_map: + if isinstance(field_map, dict): + for source_key, target_key in field_map.items(): + val = source_doc.fields.get(source_key) + if val not in (None, ""): + target_doc.fields[target_key] = val + else: + for fmap in field_map: + val = source_doc.fields.get(fmap[0]) + if val not in (None, ""): + target_doc.fields[fmap[1]] = val # map idx if source_doc.idx: From fe4561c54a55178c2aa3d0a5a952553ee165f396 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Wed, 10 Jul 2013 17:40:03 +0530 Subject: [PATCH 10/13] get_query to server side --- core/doctype/communication/communication.py | 26 +++++++++++++-------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/core/doctype/communication/communication.py b/core/doctype/communication/communication.py index ff4b050f2e..79b7d5bb41 100644 --- a/core/doctype/communication/communication.py +++ b/core/doctype/communication/communication.py @@ -123,19 +123,25 @@ class DocType(): def get_user(doctype, txt, searchfield, start, page_len, filters): from controllers.queries import get_match_cond return webnotes.conn.sql("""select name, concat_ws(' ', first_name, middle_name, last_name) - from `tabProfile` where ifnull(enabled, 0)=1 and docstatus < 2 and - (%(key)s like "%(txt)s" or concat_ws(' ', first_name, middle_name, last_name) - like "%(txt)s") - %(mcond)s limit %(start)s, %(page_len)s """ % {'key': searchfield, + from `tabProfile` + where ifnull(enabled, 0)=1 + and docstatus < 2 + and (%(key)s like "%(txt)s" + or concat_ws(' ', first_name, middle_name, last_name) like "%(txt)s") + %(mcond)s + limit %(start)s, %(page_len)s """ % {'key': searchfield, 'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype, searchfield), 'start': start, 'page_len': page_len}) def get_lead(doctype, txt, searchfield, start, page_len, filters): from controllers.queries import get_match_cond return webnotes.conn.sql(""" select name, lead_name from `tabLead` - where docstatus < 2 and (%(key)s like "%(txt)s" - or lead_name like "%(txt)s" or company_name like "%(txt)s") - %(mcond)s order by lead_name asc limit %(start)s, %(page_len)s - """ % {'key': searchfield,'txt': "%%%s%%" % txt, - 'mcond':get_match_cond(doctype, searchfield), 'start': start, - 'page_len': page_len}) \ No newline at end of file + where docstatus < 2 + and (%(key)s like "%(txt)s" + or lead_name like "%(txt)s" + or company_name like "%(txt)s") + %(mcond)s + order by lead_name asc + limit %(start)s, %(page_len)s """ % {'key': searchfield,'txt': "%%%s%%" % txt, + 'mcond':get_match_cond(doctype, searchfield), 'start': start, + 'page_len': page_len}) \ No newline at end of file From c14590e0d7726f7bc40b4e7a43a3754ea0605980 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 10 Jul 2013 18:38:46 +0530 Subject: [PATCH 11/13] [fix] [minor] language in grid and section breaks --- public/js/wn/form/grid.js | 4 +++- public/js/wn/form/layout.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/public/js/wn/form/grid.js b/public/js/wn/form/grid.js index 14ed6cc937..eb8ea55dfd 100644 --- a/public/js/wn/form/grid.js +++ b/public/js/wn/form/grid.js @@ -257,7 +257,7 @@ wn.ui.form.GridRow = Class.extend({ var colsize = 2, txt = me.doc ? wn.format(me.doc[df.fieldname], df, null, me.doc) : - df.label; + wn._(df.label); switch(df.fieldtype) { case "Text": colsize = 3; @@ -265,6 +265,8 @@ wn.ui.form.GridRow = Class.extend({ case "Check": colsize = 1; break; + case "Select": + txt = wn._(txt) } total_colsize += colsize if(total_colsize > 12) diff --git a/public/js/wn/form/layout.js b/public/js/wn/form/layout.js index 20bddf5966..7d9f267037 100644 --- a/public/js/wn/form/layout.js +++ b/public/js/wn/form/layout.js @@ -80,7 +80,7 @@ wn.ui.form.Layout = Class.extend({ $('

' + (df.options ? (' ') : "") + '' + this.labelled_section_count + ". " - + df.label + + wn._(df.label) + "

") .css({ "font-weight": "bold", From edc9dd596c8e18230a443d315036c864a844fc2e Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 10 Jul 2013 20:29:59 +0530 Subject: [PATCH 12/13] [fix] get_query where options not mentioned --- public/js/wn/form/control.js | 2 +- public/js/wn/form/link_selector.js | 2 +- webnotes/widgets/search.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/js/wn/form/control.js b/public/js/wn/form/control.js index 91dc2213f4..20274edc52 100644 --- a/public/js/wn/form/control.js +++ b/public/js/wn/form/control.js @@ -655,7 +655,7 @@ wn.ui.form.ControlLink = wn.ui.form.ControlData.extend({ source: function(request, response) { var args = { 'txt': request.term, - 'dt': me.df.options, + 'doctype': me.df.options, }; me.set_custom_query(args); diff --git a/public/js/wn/form/link_selector.js b/public/js/wn/form/link_selector.js index 7b816f1be3..4fb751e3cd 100644 --- a/public/js/wn/form/link_selector.js +++ b/public/js/wn/form/link_selector.js @@ -61,7 +61,7 @@ wn.ui.form.LinkSelector = Class.extend({ var args = { txt: this.dialog.fields_dict.txt.get_value(), doctype: this.doctype, - searchfield: this.dialog.fields_dict.search_field.get_value() + searchfield: this.dialog.fields_dict.search_field.get_value() || "name" }, me = this; diff --git a/webnotes/widgets/search.py b/webnotes/widgets/search.py index 22a42c5912..49d2eb937d 100644 --- a/webnotes/widgets/search.py +++ b/webnotes/widgets/search.py @@ -30,8 +30,8 @@ from startup.query_handlers import standard_queries # this is called by the Link Field @webnotes.whitelist() -def search_link(dt, txt, query=None, filters=None): - search_widget(dt, txt, query, page_len=10, filters=filters) +def search_link(doctype, txt, query=None, filters=None): + search_widget(doctype, txt, query, page_len=10, filters=filters) webnotes.response['results'] = build_for_autosuggest(webnotes.response["values"]) # this is called by the search box From 62b5f4c8d23b780713a9a66459ccf7dc3365f48f Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 10 Jul 2013 20:42:43 +0530 Subject: [PATCH 13/13] [feature] [website] Create Default Home Page --- templates/pages/404.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/pages/404.html b/templates/pages/404.html index 3c37a30f38..7b22882fa2 100644 --- a/templates/pages/404.html +++ b/templates/pages/404.html @@ -4,7 +4,7 @@ {% block content %}
-
+

Page missing or moved


We are very sorry for this, but the page you are looking for is missing