Skip to Content
Menu
This question has been flagged
2 Replies
13465 Views

Hi,

(Odoo V9  on CentOs7)

Is there a trusty guide to create a database template and from there create others and fill them up with data to end user's?


Ive been trying to access to Postgresql and clone a database ex.: production.domain.local, but when ever I tried to create a child database thru the web portal all apps do not load, the web interface does not load properly, I've tried to follow https://github.com/OCA/maintainer-quality-tools/issues/299 and https://www.odoo.com/es_ES/forum/ayuda-1/question/updated-how-do-i-prevent-website-common-asset-files-from-constantly-not-being-found-ioerror-errno-2-no-such-file-or-directory-92982, but without success.

Is there a way to do it manually or by using a script?

Steps done:

1- create first db called template.domain.local

2- Install all modules, configure accordingly.

3- Stop odoo service.

4- Access to postgresql db from shell using psql.

5- Clone template.domain.local to p1-template and owner odoo

6-  Modify odoo config to use new template p1-template

7- Access the other web portal as production.domain.local and create the new db as the domain expect.

- At this stage I got many errors like:  ir_attachment :No such file or directory: u'/var/lib/odoo/filestore/db-test/61/e6900asdfasfde0680....

- The loging page seems trunked and the only way to access to it is by adding .../web?debug


Thanks in advanced for help.

Avatar
Discard
Best Answer

I don't use the webgui for creating databases any longer. It failed on me once and since then for new databases I go to the command line.

First stop any Odoo running processes.

Use the createdb command to create a new database: $

 createdb newdatabasename

Then initialize the new database using the -d option: $

path/to/odoo.py/or/odoo-bin -d newdatabasename --without-demo-data=all

You could script this all, make it interactive even asking for a db name, choosing wether or not to add 'demo' data etc.

Avatar
Discard
Author Best Answer

Thanks @damon for the hint.

I have modified the procedure and it have worked in my case, this is as follow:

1- create first db called template.domain.local, all from the web UI.
2- Install all modules, configure accordingly.
3- Stop odoo service and clone database, this would be the workable DB.

Run the following, to clone the workable DB and create a master template called p1-template : 
   #> sudo -u postgres createdb p1-template --template="template.domain.local"  --owner=odoo
Run the following to avoid the error mentioned above:
   #> cp -a /var/lib/odoo/filestore/template.domain.local /var/lib/odoo/filestore/p1-template

4-  Modify odoo config to use new master template called p1-template.

5- Finally I can use either the web page or your way to create a production db:

    If I want to create production DB using your last step:

     #> sudo -u postgres createdb production.domain.local --template=p1-template --owner=odoo

     #> cp -a /var/lib/odoo/filestore/p1-template /var/lib/odoo/filestore/production.domain.local

    Run Odoo by being stopped:

     #> path/to/odoo.py/ or  /odoo-bin -d "production.domain.local" --without-demo-data=all


Perhaps there should be an error or a shorter way to do it, by It have had worked for me. Now I'll try to script it.


Thanks

Avatar
Discard