forked from nmbooker/oekit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
odoo.createdb
executable file
·42 lines (37 loc) · 1.41 KB
/
odoo.createdb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#! /usr/bin/env python
"""Make an Odoo database.
"""
import sys
import argparse
from oekit import oe_client_env
import erppeek
from funbox.once import Once # Once actually constructs a thunk
def main(options):
"""Main program."""
db = options.dbname
master_passwd = options.master_password
env = Once(oe_client_env.OEClientEnv)
url = options.url or env().url
client = erppeek.Client(server=url)
database_exists = db in client.db.list()
if database_exists:
sys.stderr.write("ERROR: Database %r already exists\n" % db)
sys.exit(3)
else:
client.create_database(master_passwd, db, demo=False, lang='en_GB', user_password=options.user_password)
return
def get_options():
"""Get options for the script."""
parser = argparse.ArgumentParser(
description="Make a new Odoo database for dev.",
)
# parser.add_argument() calls here
parser.add_argument('dbname', help='the name of the database to create')
parser.add_argument('-u', '--url', help='Override URL')
parser.add_argument('-P', '--master-password', default='admin', help='the master password if not admin')
parser.add_argument('-p', '--user-password', default='admin', help='the password to create the super user with, default: admin')
options = parser.parse_args()
# extra processing of options here
return options
if __name__ == "__main__":
main(get_options())