Ver código fonte

[fixes] in doctype, code, controller and layout

version-14
Anand Doshi 12 anos atrás
pai
commit
46c758926a
7 arquivos alterados com 26 adições e 14 exclusões
  1. +7
    -6
      core/doctype/doctype/doctype.py
  2. +4
    -3
      public/js/legacy/widgets/form/form.js
  3. +3
    -1
      public/js/wn/form/control.js
  4. +1
    -1
      public/js/wn/form/layout.js
  5. +1
    -1
      webnotes/model/bean.py
  6. +1
    -1
      webnotes/model/code.py
  7. +9
    -1
      webnotes/model/controller.py

+ 7
- 6
core/doctype/doctype/doctype.py Ver arquivo

@@ -90,18 +90,19 @@ class DocType:
from webnotes.model.db_schema import updatedb
updatedb(self.doc.name)

# update index
bean = webnotes.bean({"doctype": self.doc.name})
bean.make_controller()
if hasattr(bean.obj, "on_doctype_update"):
bean.controller.on_doctype_update()

self.change_modified_of_parent()
import conf
if (not webnotes.in_import) and getattr(conf, 'developer_mode', 0):
self.export_doc()
self.make_controller_template()
# update index
bean = webnotes.bean({"doctype": self.doc.name})
bean.make_controller()
if hasattr(bean.obj, "on_doctype_update"):
bean.controller.on_doctype_update()

webnotes.clear_cache(doctype=self.doc.name)



+ 4
- 3
public/js/legacy/widgets/form/form.js Ver arquivo

@@ -202,7 +202,7 @@ _f.Frm.prototype.setup_std_layout = function() {
parent: this.body,
doctype: this.doctype,
frm: this,
})
});
// state
this.states = new wn.ui.form.States({
@@ -391,8 +391,9 @@ _f.Frm.prototype.refresh = function(docname) {
// record switch
if(docname) {
if(this.docname != docname && (!this.meta.in_dialog || this.in_form) &&
!this.meta.istable)
scroll(0, 0);
!this.meta.istable) {
scroll(0, 0);
}
this.docname = docname;
}



+ 3
- 1
public/js/wn/form/control.js Ver arquivo

@@ -204,7 +204,9 @@ wn.ui.form.ControlInput = wn.ui.form.Control.extend({
})
}
},
set_label: function() {
set_label: function(label) {
if(label) this.df.label = label;
if(this.only_input || this.df.label==this._label)
return;
this.label_span.innerHTML = wn._(this.df.label);


+ 1
- 1
public/js/wn/form/layout.js Ver arquivo

@@ -7,7 +7,7 @@ wn.ui.form.Layout = Class.extend({
},
make: function() {
this.wrapper = $('<div class="form-layout">').appendTo(this.parent);
this.fields = wn.meta.get_docfields(this.frm.doctype);
this.fields = wn.meta.get_docfields(this.frm.doctype, this.frm.docname);
this.setup_tabbing();
},
refresh: function() {


+ 1
- 1
webnotes/model/bean.py Ver arquivo

@@ -61,7 +61,7 @@ class Bean:
"""
Load doclist from dt
"""
from webnotes.model.doc import Document, getchildren
from webnotes.model.doc import getchildren

if not dt: dt = self.doc.doctype
if not dn: dn = self.doc.name


+ 1
- 1
webnotes/model/code.py Ver arquivo

@@ -120,7 +120,7 @@ def get_doctype_class(doctype, module):
DocType = getattr(module, 'DocType')
else:
if not cint(webnotes.conn.get_value("DocType", doctype, "custom")):
raise Exception, "Unable to load module for :" + doctype
raise ImportError, "Unable to load module for: " + doctype
class DocType:
def __init__(self, d, dl):


+ 9
- 1
webnotes/model/controller.py Ver arquivo

@@ -38,6 +38,8 @@ error_condition_map = {
"^": _("cannot start with"),
}

class EmptyTableError(webnotes.ValidationError): pass

class DocListController(object):
def __init__(self, doc, doclist):
self.doc, self.doclist = doc, doclist
@@ -66,7 +68,7 @@ class DocListController(object):
val1 = cint(val1)
if not webnotes.compare(val1, condition, val2):
msg = _("Error: ")
msg = _("Error") + ": "
if doc.parentfield:
msg += _("Row") + (" # %d: " % doc.idx)
@@ -76,6 +78,12 @@ class DocListController(object):
# raise passed exception or True
msgprint(msg, raise_exception=raise_exception or True)
def validate_table_has_rows(self, parentfield, raise_exception=None):
if not self.doclist.get({"parentfield": parentfield}):
label = self.meta.get_label(parentfield)
msgprint(_("Error") + ": " + _(label) + " " + _("cannot be empty"),
raise_exception=raise_exception or EmptyTableError)
def round_floats_in(self, doc, fieldnames=None):
if not fieldnames:
fieldnames = [df.fieldname for df in self.meta.get({"doctype": "DocField", "parent": doc.doctype,


Carregando…
Cancelar
Salvar