Skip to Content

Welcome!

This community is for professionals and enthusiasts of our products and services.
Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

You need to be registered to interact with the community.
This question has been flagged
1 Reply
2300 Views

一个数据库有三个scheme, odoo如何配置指定连接哪一个作为本实例的数据?

如果不能配置,怎么开发实现在连接时指定 scheme

Avatar
Discard
Author

在Odoo中,每个数据库只有一个schema,默认情况下是“public”。如果您想要使用其他的schema,则需要创建新的数据库用户并授予对该特定schema的访问权限。然后,在Odoo配置文件中,您可以指定用于连接到PostgreSQL数据库的用户名和密码。

例如,假设我们已经为我们的Odoo实例创建了名为“mydatabase”的数据库,并且在该数据库中有三个模式:“public”,“sales”和“inventory”。现在,我们想要将Odoo与模式“sales”关联起来。以下是如何完成此操作:

1. 创建新用户并授予权限

首先,我们需要创建一个新用户并向其授予对模式"sales" 的访问权限。

```
CREATE USER odoo_sales WITH PASSWORD 'password';
GRANT ALL PRIVILEGES ON SCHEMA sales TO odoo_sales;
```

2. 配置odoo.conf文件

接下来,在odoo.conf文件中添加以下行以指定用于连接到PostgreSQL服务器的用户名和密码:

```
[options]
db_user = odoo_sales
db_password = password
```

这将使Odoo使用名为 "odoo_sales" 的用户身份连接到PostgreSQL服务器,并仅查看具有名称 "sales" 的模式。

如果不能通过以上方法进行配置,则可以考虑编写自定义代码或插件以覆盖默认行为。例如,在启动时可以更改默认连接参数或使用不同的库客户端程序等方式进行处理。

Avatar
Discard

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!