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.

0

Database list method in openerp

By
ThackerS (ts)
on 8/19/14, 10:41 PM 1,274 views

Hi.
In openerp login page, we have database list.
I want to know the method in openerp which provide this list.
NB: the method is a python code
Thank you.

0
ThackerS (ts)
On 8/20/14, 10:19 PM

Hi dear friends.
The database list in openerp login page is provide by the method def exp_list(self,document=False) which is in /openerp/service/web_services

def exp_list(self, document=False):
        if not tools.config['list_db'] and not document:
            raise openerp.exceptions.AccessDenied()
        chosen_template = tools.config['db_template']
        templates_list = tuple(set(['template0', 'template1', 'postgres', chosen_template]))
        db = sql_db.db_connect('postgres')
        cr = db.cursor()
        try:
            try:
                db_user = tools.config["db_user"]
                if not db_user and os.name == 'posix':
                    import pwd
                    db_user = pwd.getpwuid(os.getuid())[0]
                if not db_user:
                    cr.execute("select usename from pg_user where usesysid=(select datdba from pg_database where datname=%s)", (tools.config["db_name"],))
                    res = cr.fetchone()
                    db_user = res and str(res[0])
                if db_user:
                    cr.execute("select datname from pg_database where datdba=(select usesysid from pg_user where usename=%s) and datname not in %s order by datname", (db_user, templates_list))
                else:
                    cr.execute("select datname from pg_database where datname not in %s order by datname", (templates_list,))
                res = [tools.ustr(name) for (name,) in cr.fetchall()]
            except Exception:
                res = []
        finally:
            cr.close()
        res.sort()
        return res

Best reagrds.

0
Deviprasad V
On 8/20/14, 1:30 AM

Hi,

Ther is a method named "db_list". Inside the web module -> controllers -> main.py


This method gives the full list of db names

0

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 8/20/14, 1:22 AM

In python Dabase list source code location:  /addons/web/controllers/main.py

Line No 704

class Database(openerpweb.Controller):
    _cp_path = "/web/database"

    @openerpweb.jsonrequest
    def get_list(self, req):
        return db_list(req)
               

In JavaScript Dabase list source code location:  /addons/web/static/src/js/chrome.js

Line no: 367

  start: function() {
        var self = this;
        $('.oe_secondary_menus_container,.oe_user_menu_placeholder').empty();
        var fetch_db = this.rpc("/web/database/get_list", {}).then(
            function(result) {
                self.db_list = result;
            },

 

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

1 follower(s)

Stats

Asked: 8/19/14, 10:41 PM
Seen: 1274 times
Last updated: 3/16/15, 8:10 AM