[FIX] Implement get languages function.

bzr revid: noz@tinyerp.com-20110701065842-a9nlwe33lrco3siu
This commit is contained in:
noz (OpenERP) 2011-07-01 12:28:42 +05:30
parent 092f442dc1
commit 1f44208fd7
4 changed files with 26 additions and 19 deletions

View File

@ -110,6 +110,15 @@ class Session(openerpweb.Controller):
dbs = proxy.list() dbs = proxy.list()
return {"db_list": dbs} return {"db_list": dbs}
@openerpweb.jsonrequest
def get_lang_list(self, req):
lang_list = [('en_US', 'English (US)')]
try:
lang_list = lang_list + (req.session.proxy("db").list_lang() or [])
except Exception, e:
pass
return {"lang_list": lang_list}
@openerpweb.jsonrequest @openerpweb.jsonrequest
def modules(self, req): def modules(self, req):

View File

@ -189,6 +189,10 @@ ul.db_options li {
-moz-border-radius: 10px; -moz-border-radius: 10px;
} }
.db_option_table input[type="text"], input[type="password"], select, textarea {
width: 300px;
}
.option_string { .option_string {
font-weight: bold; font-weight: bold;
color: #555; color: #555;

View File

@ -927,6 +927,10 @@ openerp.base.Database = openerp.base.Controller.extend({
self.db_list = result.db_list; self.db_list = result.db_list;
}); });
this.rpc("/base/session/get_lang_list", {}, function(result) {
self.lang_list = result.lang_list;
});
this.$element.find('#db-create').click(function() { this.$element.find('#db-create').click(function() {
self.db_string = "CREATE DATABASE"; self.db_string = "CREATE DATABASE";
self.$option_id.html(QWeb.render("CreateDB", self)); self.$option_id.html(QWeb.render("CreateDB", self));

View File

@ -95,9 +95,13 @@
<tr> <tr>
<td><label for="db_lang">Default language:</label></td> <td><label for="db_lang">Default language:</label></td>
<td> <td>
<select name="db"> <t t-if="lang_list">
<select name="db_lang">
</select> <t t-foreach="lang_list" t-as="lang">
<option t-att-value="lang[0]"><t t-esc="lang[1]"/></option>
</t>
</select>
</t>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -127,14 +131,7 @@
<t t-if="db_list"> <t t-if="db_list">
<select name="db"> <select name="db">
<t t-foreach="db_list" t-as="db"> <t t-foreach="db_list" t-as="db">
<t t-if="selected_db === db"> <option t-att-value="db"><t t-esc="db"/></option>
<option t-att-value="db" selected="true">
<t t-esc="db"/>
</option>
</t>
<t t-if="selected_db !== db">
<option t-att-value="db"><t t-esc="db"/></option>
</t>
</t> </t>
</select> </select>
</t> </t>
@ -163,14 +160,7 @@
<t t-if="db_list"> <t t-if="db_list">
<select name="db"> <select name="db">
<t t-foreach="db_list" t-as="db"> <t t-foreach="db_list" t-as="db">
<t t-if="selected_db === db"> <option t-att-value="db"><t t-esc="db"/></option>
<option t-att-value="db" selected="true">
<t t-esc="db"/>
</option>
</t>
<t t-if="selected_db !== db">
<option t-att-value="db"><t t-esc="db"/></option>
</t>
</t> </t>
</select> </select>
</t> </t>