How do I specify database in odoo Controller

122 Views Asked by At

How do I specify database in odoo Controller rather than select it manually from the browser?

My code

@http.route('/test/', type='http', auth='public', website=True, db='test')
    def index(self, **kw):
        return "Salutation"

this is what I did and then if I went to localhost:8069/test/ I got 404 Not found error. but if I go to localhost:8069/database/selector and select the database I get the right response. How do I specify the database in odoo Controller rather than select it manually from the browser

1

There are 1 best solutions below

0
On

On your server, in src/odoo, you should create a new file: my_odoo_configuration.conf, where you can store the information about the main database you are using:

[options]
addons_path = ...
...
db_name = my_database_2

And you can switch the database when launching odoo from the command line:

/src/odoo/odoo-bin -c my_odoo_configuration.conf -d my_database_1 ... 

More configuration details can be found on the official documentation: https://www.odoo.com/documentation/16.0/developer/reference/cli.html#database