@@ -35,7 +35,8 @@ cur_frm.fields_dict.doc_type.get_query = function(doc, dt, dn) { | |||||
return 'SELECT name FROM `tabDocType` \ | return 'SELECT name FROM `tabDocType` \ | ||||
WHERE IFNULL(issingle,0)=0 AND \ | WHERE IFNULL(issingle,0)=0 AND \ | ||||
IFNULL(in_create, 0)=0 AND \ | IFNULL(in_create, 0)=0 AND \ | ||||
module != "Core" AND \ | |||||
name not in ("DocType", "DocField", "DocPerm", "Profile", "Role", "UserRole", "Page", \ | |||||
"Page Role", "Module Def", "Print Format", "Report", "Search Criteria") AND \ | |||||
name LIKE "%s%%" ORDER BY name ASC LIMIT 50'; | name LIKE "%s%%" ORDER BY name ASC LIMIT 50'; | ||||
} | } | ||||
@@ -55,6 +55,7 @@ def get_bootinfo(): | |||||
add_home_page(bootinfo, doclist) | add_home_page(bootinfo, doclist) | ||||
add_allowed_pages(bootinfo) | add_allowed_pages(bootinfo) | ||||
load_translations(bootinfo) | load_translations(bootinfo) | ||||
load_country_and_currency(bootinfo, doclist) | |||||
# ipinfo | # ipinfo | ||||
if webnotes.session['data'].get('ipinfo'): | if webnotes.session['data'].get('ipinfo'): | ||||
@@ -77,6 +78,12 @@ def get_bootinfo(): | |||||
return bootinfo | return bootinfo | ||||
def load_country_and_currency(bootinfo, doclist): | |||||
country_doc = webnotes.doc("Country", bootinfo.sysdefaults.country) | |||||
doclist += [country_doc] | |||||
if country_doc.currency: | |||||
doclist += [webnotes.doc("Currency", country_doc.currency)] | |||||
def add_allowed_pages(bootinfo): | def add_allowed_pages(bootinfo): | ||||
bootinfo.allowed_pages = [p[0] for p in webnotes.conn.sql("""select distinct parent from `tabPage Role` | bootinfo.allowed_pages = [p[0] for p in webnotes.conn.sql("""select distinct parent from `tabPage Role` | ||||
where role in ('%s')""" % "', '".join(webnotes.get_roles()))] | where role in ('%s')""" % "', '".join(webnotes.get_roles()))] | ||||
@@ -17,4 +17,18 @@ def get_all(): | |||||
all_data = json.loads(local_info.read()) | all_data = json.loads(local_info.read()) | ||||
return all_data | return all_data | ||||
def update(): | |||||
with open(os.path.join(os.path.dirname(__file__), "currency_info.json"), "r") as nformats: | |||||
nformats = json.loads(nformats.read()) | |||||
all_data = get_all() | |||||
for country in all_data: | |||||
data = all_data[country] | |||||
data["number_format"] = nformats.get(data.get("currency", "default"), | |||||
nformats.get("default"))["display"] | |||||
print all_data | |||||
with open(os.path.join(os.path.dirname(__file__), "country_info.json"), "w") as local_info: | |||||
local_info.write(json.dumps(all_data, indent=1)) |
@@ -339,11 +339,18 @@ class Database: | |||||
return self.get_default(key, parent) | return self.get_default(key, parent) | ||||
else: | else: | ||||
res = self.sql("""select defkey, defvalue from `tabDefaultValue` | res = self.sql("""select defkey, defvalue from `tabDefaultValue` | ||||
where parent = %s""", parent) | |||||
d = {} | |||||
for rec in res: | |||||
d[rec[0]] = rec[1] or '' | |||||
return d | |||||
where parent = %s""", parent, as_dict=1) | |||||
defaults = webnotes._dict({}) | |||||
for d in res: | |||||
if d.defkey in defaults: | |||||
# listify | |||||
if isinstance(defaults[d.defkey], basestring): | |||||
defaults[d.defkey] = [defaults[d.defkey]] | |||||
defaults[d.defkey].append(d.defvalue) | |||||
else: | |||||
defaults[d.defkey] = d.defvalue | |||||
return defaults | |||||
def begin(self): | def begin(self): | ||||
if not self.in_transaction: | if not self.in_transaction: | ||||
@@ -46,7 +46,10 @@ def get(doctype, processed=False, cached=True): | |||||
"""return doclist""" | """return doclist""" | ||||
if cached: | if cached: | ||||
doclist = from_cache(doctype, processed) | doclist = from_cache(doctype, processed) | ||||
if doclist: return DocTypeDocList(doclist) | |||||
if doclist: | |||||
if processed: | |||||
add_linked_with(doclist) | |||||
return DocTypeDocList(doclist) | |||||
load_docfield_types() | load_docfield_types() | ||||
@@ -65,7 +68,6 @@ def get(doctype, processed=False, cached=True): | |||||
expand_selects(doclist) | expand_selects(doclist) | ||||
add_print_formats(doclist) | add_print_formats(doclist) | ||||
add_search_fields(doclist) | add_search_fields(doclist) | ||||
add_linked_with(doclist) | |||||
add_workflows(doclist) | add_workflows(doclist) | ||||
update_language(doclist) | update_language(doclist) | ||||
@@ -76,6 +78,9 @@ def get(doctype, processed=False, cached=True): | |||||
add_precision(doctype, doclist) | add_precision(doctype, doclist) | ||||
to_cache(doctype, processed, doclist) | to_cache(doctype, processed, doclist) | ||||
if processed: | |||||
add_linked_with(doclist) | |||||
return DocTypeDocList(doclist) | return DocTypeDocList(doclist) | ||||