[IMP]Docker / Odoo databses management with duplicate name and optional admin pass for database

This commit is contained in:
Fabien Bourgeois 2017-01-11 10:05:53 +01:00
parent fb83b0aeab
commit 89bb1948ce

View File

@ -15,18 +15,20 @@ def main():
parser = common.parser(parser) parser = common.parser(parser)
parser.add_argument('-a', '--action', type=str, default='create', parser.add_argument('-a', '--action', type=str, default='create',
help='action for the database,' + help='action for the database,' +
'default to create') 'default to create (others are drop, duplicate)')
parser.add_argument('-d', '--database', type=str, required=True, parser.add_argument('-d', '--database', type=str, required=True,
help='the targetted database') help='the targetted database')
parser.add_argument('-dn', '--duplicate-name', type=str,
help=('name for duplicated database (optional : '
'name_copy otherwise'))
parser.add_argument('-pw', '--password', type=str, required=True, parser.add_argument('-pw', '--password', type=str, required=True,
help='the odoo superadmin password') help='the odoo superadmin password')
parser.add_argument('-dm', '--demo', type=str, default='False', parser.add_argument('-dm', '--demo', type=str, default='False',
help='demonstration data') help='demonstration data')
parser.add_argument('-l', '--lang', type=str, default='fr_FR', parser.add_argument('-l', '--lang', type=str, default='fr_FR',
help='default language') help='default language')
parser.add_argument('-dbpw', '--database_password', type=str, parser.add_argument('-dbpw', '--database_password', type=str, default='admin',
required=True, help='the database admin password, default to admin')
help='the database admin password')
args = parser.parse_args() args = parser.parse_args()
# Connection # Connection
@ -46,8 +48,8 @@ def main():
elif args.action == 'drop': elif args.action == 'drop':
odoo.db.drop(args.password, args.database) odoo.db.drop(args.password, args.database)
elif args.action == 'duplicate': elif args.action == 'duplicate':
odoo.db.duplicate(args.password, args.database, args.database + name = args.duplicate_name or args.database + '_copy'
'_copy') odoo.db.duplicate(args.password, args.database, name)
if __name__ == "__main__": if __name__ == "__main__":
main() main()