From d15271c27d45a09a98aec8a40ce02768c69e109f Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 14 Nov 2012 12:23:04 +0530 Subject: [PATCH] do not allow mandatory and hidden and also bugfix in communication creation --- core/doctype/doctype/doctype.py | 12 ++++++++++-- public/js/wn/ui/listing.js | 1 + public/js/wn/views/doclistview.js | 1 + webnotes/utils/email_lib/form_email.py | 7 ++++--- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/core/doctype/doctype/doctype.py b/core/doctype/doctype/doctype.py index 32c5df1bf3..8c1530044c 100644 --- a/core/doctype/doctype/doctype.py +++ b/core/doctype/doctype/doctype.py @@ -190,9 +190,16 @@ def validate_fields(fields): def check_link_table_options(d): if d.fieldtype in ("Link", "Table"): if not d.options: - webnotes.msgprint("""#%(idx)s %(label)s: Options must be specified for Link and Table type fields""" % d.fields, raise_exception=1) + webnotes.msgprint("""#%(idx)s %(label)s: Options must be specified for Link and Table type fields""" % d.fields, + raise_exception=1) if not webnotes.conn.exists("DocType", d.options): - webnotes.msgprint("""#%(idx)s %(label)s: Options %(options)s must be a valid "DocType" for Link and Table type fields""" % d.fields, raise_exception=1) + webnotes.msgprint("""#%(idx)s %(label)s: Options %(options)s must be a valid "DocType" for Link and Table type fields""" % d.fields, + raise_exception=1) + + def check_hidden_and_mandatory(d): + if d.hidden and d.reqd: + webnotes.msgprint("""#%(idx)s %(label)s: Cannot be hidden and mandatory (reqd)""" % d.fields, + raise_exception=True) for d in fields: if not d.permlevel: d.permlevel = 0 @@ -202,4 +209,5 @@ def validate_fields(fields): check_unique_fieldname(d.fieldname) check_illegal_mandatory(d) check_link_table_options(d) + check_hidden_and_mandatory(d) \ No newline at end of file diff --git a/public/js/wn/ui/listing.js b/public/js/wn/ui/listing.js index 1597117b5c..696b9f9d8e 100644 --- a/public/js/wn/ui/listing.js +++ b/public/js/wn/ui/listing.js @@ -223,6 +223,7 @@ wn.ui.Listing = Class.extend({ if(!me.opts.no_loading) me.set_working(true); + wn.call({ method: this.opts.method || 'webnotes.widgets.query_builder.runquery', args: this.get_call_args(a0), diff --git a/public/js/wn/views/doclistview.js b/public/js/wn/views/doclistview.js index 6d92c32eec..ba2e3e28e1 100644 --- a/public/js/wn/views/doclistview.js +++ b/public/js/wn/views/doclistview.js @@ -146,6 +146,7 @@ wn.views.DocListView = wn.ui.Listing.extend({ method: 'webnotes.widgets.doclistview.get', get_args: this.get_args, parent: this.wrapper, + freeze: true, start: 0, page_length: this.page_length, show_filters: true, diff --git a/webnotes/utils/email_lib/form_email.py b/webnotes/utils/email_lib/form_email.py index df335c2880..4f186f9eb4 100644 --- a/webnotes/utils/email_lib/form_email.py +++ b/webnotes/utils/email_lib/form_email.py @@ -162,15 +162,16 @@ class FormEmail: comm_cols = [c[0] for c in webnotes.conn.sql("""desc tabCommunication""")] # tag to record - if self.dt in comm_cols: - comm.fields[self.dt] = self.dn + dt = self.dt.lower().replace(" ", "_") + if dt in comm_cols: + comm.fields[dt] = self.dn # tag to customer, supplier (?) if self.customer: comm.customer = self.customer if self.supplier: comm.supplier = self.supplier - + comm.save(1) except Exception, e: if e.args[0]!=1146: raise e