do not allow mandatory and hidden and also bugfix in communication creation

This commit is contained in:
Rushabh Mehta 2012-11-14 12:23:04 +05:30
parent d948cf6823
commit d15271c27d
4 changed files with 16 additions and 5 deletions

View file

@ -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)

View file

@ -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),

View file

@ -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,

View file

@ -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