1

What I want to do is to login with differents users into the same PostgreSQL database. I need to get this done due to some circunstances that I am not going to describe here (too long).

First try

I have read this documentation page about PostgreSQL Roles. So I have created both users and inherit the permissions from one to the another

CREATE ROLE odoo WITH LOGIN CREATEDB REPLICATION PASSWORD 'odoo' NOINHERIT;
CREATE ROLE odoo_inherit WITH LOGIN CREATEDB REPLICATION PASSWORD 'odoo_inherit' INHERIT;
GRANT odoo TO odoo_inherit;

This is the result:

    Role name    |                         Attributes       | Member of 
-----------------+------------------------------------------+-----------
 odoo            | No inheritance, Create DB, Replication   | {}
 odoo_inherit    | Create DB, Replication                   | {odoo}

Second try

I have tried faking the PostgreSQL role, but I cannot login neither from Odoo:

ALTER USER odoo_inherit SET ROLE odoo;

And in fact, when I create a table with the role odoo_inherit the new owner of the new table is odoo

Results

The databases owned by the odoo role are invisible for the odoo_inherit user within Odoo. However I can log in the database with this psql command

psql -U odoo_inherit -d dbname -W

Is there a way to achieve this? Is it a Odoo limitation? Am I missing anything?

Note: I have tried that because these are the answers of this other SO question

ChesuCR
  • 9,352
  • 5
  • 51
  • 114
  • There is nothing in documentation says that you can do this. You can try to use two instance of Odoo every instance with it's user if that help you. What you need it's not that simple how Odoo will know witch user you need to use what is the condition for that. But i think if you really reallt need that you need to change the framework's code – Charif DZ Jun 16 '18 at 08:16
  • @cherif thanks for your attention. Yes, actually I have two instances. One of them with the user `odoo` and the other one with the user `odoo_inherit`. If I log in with `psql`, it works with for both roles. If I log in within Odoo, only the `odoo` role works. I would like to know the reason why is this not working? What login method is Odoo using? – ChesuCR Jun 17 '18 at 10:34
  • But what is the error that it give you ? – Charif DZ Jun 17 '18 at 12:35
  • @cherif I don´t get any error, simply I don´t see the database in the dropdown list – ChesuCR Jun 18 '18 at 09:18

1 Answers1

0

You can change that in list_dbs(force=False):, exactly in WHERE clauses.

Kenly
  • 24,317
  • 7
  • 44
  • 60