Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

5

Database List hiding issue in Login Page.

By
Remya
on 12/18/13, 1:40 AM 3,938 views

I have a Linode Server. I installed openerp in the server. Next i hide the database list using the below code

/etc/openerp-server.conf file

code: list_db = False

Then save ans restart openerp-server service.

After i login from a external system, I cant login to that particular database.

So i removed the code from conf file and login, then there is no issue.

How can i hide the database list without any issue?

6

Gopakumar N G

--Gopakumar N G--
1198
| 5 3 7
Cochin, India
--Gopakumar N G--

Senior Software Engineer at BroadTech IT Solutions Pvt. Ltd.

Gopakumar N G
On 12/18/13, 2:45 AM

Hi, you can edit this in the base.xml of your web module (path: addons/web/static/src/xml/base.xml). The DB list is defined as

<t t-name="Login.dblist">
<select name="db">
    <t t-foreach="db_list" t-as="db">
        <t t-if="selected_db === db">
            <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>
</select>
</t>

Now replace that selection "db" with a text box with the same name of the selection field as

 <t t-name="Login.dblist">
<input name="db" type="text" value="" autofocus="autofocus"/>
 </t>

EDIT :

Then in chrome.js (addons/web/static/src/js/chrome.js) comment the on_db_loaded method (line 676-690) , which is

on_db_loaded: function (result) {
    var self = this;
    this.db_list = result;
    if (!this.selected_db) {
        this.selected_db = result[0];
    }
    this.$("[name=db]").replaceWith(QWeb.render('Login.dblist', { db_list: this.db_list, selected_db: this.selected_db}));
    if(this.db_list.length === 0) {
        this.do_action("database_manager");
    } else if(this.db_list.length === 1) {
        this.$('div.oe_login_dbpane').hide();
    } else {
        this.$('div.oe_login_dbpane').show();
    }
},

comment the above full code.

Then save the files and reload your web page, you don't need to restart the server or upgrade the module as you are editing on files in static folder. Now the dropdown will be displayed as a text field as

DB LIST

EDIT 2

@Sureka

After you have changed the database text field to the center of the page comment the code in chrome.js (addons/web/static/src/js/chrome.js) as shown below:

database_selected: function(db) {
//        var params = $.deparam.querystring();
//        params.db = db;
//        this.remember_last_used_database(db);
//        this.$('.oe_login_dbpane').empty().text(_t('Loading...'));
//        this.$('[name=login], [name=password]').prop('readonly', true);
//        instance.web.redirect('/?' + $.param(params));
    },

which is just above the on_db_loaded method. Then refresh the login page and try to login.

Its not working. I give database name in text field. After that i click on the username text box, the page is refreshing. So i first entered username,password then database, but it also refreshing the page.

Remya
on 12/18/13, 5:10 AM

Are working in v7? I have tested it in v6.1. Anyway let me check it.

Gopakumar N G
on 12/18/13, 5:16 AM

Working with openerp7.

Remya
on 12/18/13, 5:31 AM

I have updated the answer. Now check.

Gopakumar N G
on 12/18/13, 5:36 AM

Thanks. Its working.

Remya
on 12/18/13, 5:38 AM

@Gopakumar and Remya , I have a question about this. With addition to that I need to move the Database field to the center of the page above the Username field. I could achieve that but after entering the database name the page gets reloading. Even I tried with username and password first and then database , then also the page gets refreshing. I am using OpenERP v7

GG
on 3/5/14, 6:37 AM

@Sureka what are the changes you have added ?

Gopakumar N G
on 3/5/14, 9:15 AM

<t t-extend="Login"> <t t-jquery="div.oe_login_dbpane" t-operation="replace"> <form action="" method="post"> <ul> <li>Database</li> <li><input name="db" type="text" value="" autofocus="autofocus"/></li> </ul> </form> </t>

GG
on 3/5/14, 9:21 AM

@Gopakumar, In a separate custom module in static/src/xml/base.xml , I have included the above code mentioned in previous comment of mine to get the Database name as an text field and also the code to remove ''Manage Database' link. I also commented the lines 676-690 in chrome.js. Sorry I couldn't present my code clearly in above comment.

GG
on 3/5/14, 9:30 AM

@Sureka: I have updated the answer. Please check.

Gopakumar N G
on 3/6/14, 3:39 AM

@Gopakumar, Now after editing in chrome.js , I can't even log in. If I click login button nothing happens after that.

GG
on 3/10/14, 5:35 AM

@Sureka, But its working in my system. Did you just comment the code in the "database_selected: function(db)" or the method itself?

Gopakumar N G
on 3/11/14, 6:58 AM

@Gopakumar, Now its working.Sorry there was a mistake in my base xml. I should extend the class oe_login_pane.But initially i extended the oe_login_dbpane, so I can't login. Sorry once again. and thanks for your answer and reviews.

GG
on 3/11/14, 10:10 AM
3
Jasad
On 12/18/13, 2:45 AM

Hi Remya,

When you run the openerp server as service, you can make use of the --db-filter=db_name option.

ie, ./openerp-server --db-filter=test_7_db

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 12/18/13, 1:40 AM
Seen: 3938 times
Last updated: 10/28/15, 6:10 AM