[fixes] buying/selling price lists, communication and website settings

This commit is contained in:
Anand Doshi
2013-06-12 17:40:36 +05:30
parent 9c901e75cd
commit 060d9248d3
23 changed files with 162 additions and 67 deletions

View File

@@ -17,29 +17,45 @@
// update parent select
$.extend(cur_frm.cscript, {
onload_post_render: function(doc) {
// get labels of parent items
var get_parent_options = function(table_field) {
var items = getchildren('Top Bar Item', doc.name, table_field);
var main_items = [''];
for(var i in items) {
var d = items[i];
if(!d.parent_label) {
main_items.push(d.label);
}
}
return main_items.join('\n');
this.set_parent_label_options();
},
label: function(doc, cdt, cdn) {
var item = wn.model.get_doc(cdt, cdn);
if(item.parentfield === "top_bar_items") {
this.set_parent_label_options();
}
},
parent_label: function(doc, cdt, cdn) {
this.label(doc, cdt, cdn);
},
url: function(doc, cdt, cdn) {
this.label(doc, cdt, cdn);
}
set_parent_label_options: function() {
wn.meta.get_docfield("Top Bar Item", "parent_label", cur_frm.docname).options =
this.get_parent_options("top_bar_items");
// bind function to refresh fields
// when "Parent Label" is select, it
// should automatically update
// options
$(cur_frm.fields_dict['top_bar_items'].grid.get_field('parent_label').wrapper)
.bind('refresh', function() {
this.fieldobj.refresh_options(get_parent_options('top_bar_items'));
});
if($(cur_frm.fields_dict.top_bar_items.grid.wrapper).find(".grid-row-open")) {
cur_frm.fields_dict.top_bar_items.grid.refresh();
}
},
// get labels of parent items
get_parent_options: function(table_field) {
var items = getchildren('Top Bar Item', cur_frm.doc.name, table_field);
var main_items = [''];
for(var i in items) {
var d = items[i];
if(!d.parent_label && !d.url && d.label) {
main_items.push(d.label);
}
}
return main_items.join('\n');
}
});

View File

@@ -15,12 +15,39 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
from webnotes import _, msgprint
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def validate(self):
self.set_home_page()
self.validate_top_bar_items()
self.validate_footer_items()
def validate_top_bar_items(self):
"""validate url in top bar items"""
for top_bar_item in self.doclist.get({"parentfield": "top_bar_items"}):
if top_bar_item.parent_label:
parent_label_item = self.doclist.get({"parentfield": "top_bar_items",
"label": top_bar_item.parent_label})
if not parent_label_item:
# invalid item
msgprint(_(self.meta.get_label("parent_label", parentfield="top_bar_items")) +
(" \"%s\": " % top_bar_item.parent_label) + _("does not exist"), raise_exception=True)
elif not parent_label_item[0] or parent_label_item[0].url:
# parent cannot have url
msgprint(_("Top Bar Item") + (" \"%s\": " % top_bar_item.parent_label) +
_("cannot have a URL, because it has child item(s)"), raise_exception=True)
def validate_footer_items(self):
"""clear parent label in footer"""
for footer_item in self.doclist.get({"parentfield": "footer_items"}):
footer_item.parent_label = None
def on_update(self):
# make js and css
@@ -32,10 +59,7 @@ class DocType:
clear_cache()
def set_home_page(self):
import webnotes
from webnotes.model.doc import Document
webnotes.conn.sql("""delete from `tabDefault Home Page` where role='Guest'""")
d = Document('Default Home Page')