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..79b7d5bb41 100644
--- a/core/doctype/communication/communication.py
+++ b/core/doctype/communication/communication.py
@@ -119,3 +119,29 @@ 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..e27a4480ce 100644
--- a/core/doctype/custom_field/custom_field.js
+++ b/core/doctype/custom_field/custom_field.js
@@ -55,10 +55,12 @@ 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']
+ ]
+ }
}
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 602ee04afd..8ac191ee7b 100644
--- a/core/doctype/customize_form/customize_form.js
+++ b/core/doctype/customize_form/customize_form.js
@@ -42,13 +42,14 @@ 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']
+ ]
+ }
}
cur_frm.cscript.refresh = function(doc, dt, dn) {
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/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/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/grid.js b/public/js/wn/form/grid.js
index bc89cc353e..eb8ea55dfd 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,12 +252,12 @@ 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 ?
wn.format(me.doc[df.fieldname], df, null, me.doc) :
- df.label;
+ wn._(df.label);
switch(df.fieldtype) {
case "Text":
colsize = 3;
@@ -254,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)
@@ -323,11 +336,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 +357,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])
@@ -367,6 +383,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() {
diff --git a/public/js/wn/form/layout.js b/public/js/wn/form/layout.js
index 14e227a2e6..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",
@@ -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");
},
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/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
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 6e326daca5..53b02fdcc0 100644
--- a/webnotes/model/mapper.py
+++ b/webnotes/model/mapper.py
@@ -33,15 +33,18 @@ def get_mapped_doclist(from_doctype, from_docname, table_maps, target_doclist=[]
source = webnotes.bean(from_doctype, from_docname)
- if not ignore_permissions and not webnotes.has_permission(from_doctype, doc=source.doc):
+ if not ignore_permissions and not webnotes.has_permission(from_doctype, "read", source.doc):
webnotes.msgprint("No Permission", raise_exception=webnotes.PermissionError)
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"])
@@ -99,10 +102,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:
diff --git a/webnotes/widgets/reportview.py b/webnotes/widgets/reportview.py
index 0e710f3cc1..7c22ed36fc 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:
if isinstance(f, basestring):
@@ -182,7 +184,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])
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