Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added duplicate_database wrapper. #96

Merged
merged 3 commits into from Jan 30, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/api.rst
Expand Up @@ -32,6 +32,8 @@ list or install Odoo add-ons.

.. automethod:: Client.create_database

.. automethod:: Client.duplicate_database

.. automethod:: Client.login

.. attribute:: Client.context
Expand Down
29 changes: 29 additions & 0 deletions docs/tutorial.rst
Expand Up @@ -120,6 +120,35 @@ Default password is ``"admin"``.
Then we connect to any environment with ``erppeek --env demo`` or switch
during an interactive session with ``client.connect('demo')``.

Duplicate a database
--------------------

It is sometimes useful to duplicate a databases (testing, backup,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove 's' of databases

migration, ...). A shortcut is available for that, the required
parameters are the original database name, the new database name and
the superadmin password (this is the ``admin_passwd`` in the
``openerp-server.conf`` file). Default password is ``"admin"``.

.. note:: This password gives full control on the databases. Set a strong
password in the configuration to prevent unauthorized access.


.. sourcecode:: pycon

>>> client.duplicate_database('super_password', 'demo', 'demo_test')
Logged in as 'admin'
>>> client
<Client 'http://localhost:8069#demo_test'>
>>> client.db.list()
['demo_test']
>>> client.user
'admin'
>>> client.modules(installed=True)
{'installed': ['base', 'web', 'web_mobile', 'web_tests']}
>>> len(client.modules()['uninstalled'])
202
>>> #


Find the users
--------------
Expand Down
7 changes: 6 additions & 1 deletion erppeek.py
Expand Up @@ -660,7 +660,12 @@ def create_database(self, passwd, database, demo=False, lang='en_US',

def duplicate_database(self, passwd, db_original_name, db_name,
user_password='admin'):
"""Duplicate an existing database."""
"""Duplicate an existing database.

The superadmin `passwd`, `db_original_name` and `db_name` are
mandatory.
Wait for the thread to finish and login if successful.
"""
self.db.duplicate_database(passwd, db_original_name, db_name)
return self.login('admin', user_password, database=db_name)

Expand Down