示例#1
0
    def _create_db(self, template_db, db_name, demo, lang='en_US'):
        """Synchronous db creation"""
        if self.type == 'local':
            # to avoid installing extra modules we need this condition
            if tools.config['init']:
                tools.config['init'] = {}

            # we don't need tests in templates and builds
            test_enable = tools.config['test_enable']
            if test_enable:
                tools.config['test_enable'] = {}

        for r in self:
            if r.type != 'local':
                continue

            if template_db:
                db._drop_conn(self.env.cr, template_db)
                db.exp_duplicate_database(template_db, db_name)
            else:
                db.exp_create_database(
                    db_name, demo, lang)

        if test_enable:
            tools.config['test_enable'] = test_enable
示例#2
0
 def create_database(self, template_db=None, demo=False, lang='en_US'):
     self.ensure_one()
     new_db = self.name
     res = {}
     if template_db:
         db._drop_conn(self.env.cr, template_db)
         db.exp_duplicate_database(template_db, new_db)
     else:
         password = random_password()
         res.update({'superuser_password': password})
         db.exp_create_database(new_db, demo, lang, user_password=password)
     self.state = 'open'
     return res
示例#3
0
    def create_database(self, template_db=None, demo=False, lang='en_US'):
        self.ensure_one()
        new_db = self.db_name
        res = {}
        if new_db in database.list_dbs():
            raise UserError(_('Database Already Exist!'))
        if template_db:
            database._drop_conn(self.env.cr, template_db)
            database.exp_duplicate_database(template_db, new_db)
        else:
            # password = random_password()
            # res.update({'superuser_password': password})
            database.exp_create_database(new_db, demo, lang)
        if not self.is_template_db:
            self.upgrade_database({'params': True})
        _logger.info('Database created Successfully')

        return res
示例#4
0
    def create_db(self, template_db, db_name, demo, lang="en_US"):
        # to avoid installing extra modules we need this condition
        if tools.config["init"]:
            tools.config["init"] = {}

        # we don't need tests in templates and builds
        test_enable = tools.config["test_enable"]
        if test_enable:
            tools.config["test_enable"] = {}

        try:
            if template_db:
                # TODO: does drop connection works ok?
                with sql_db.db_connect(template_db).cursor() as cr:
                    db._drop_conn(cr, template_db)
                db.exp_duplicate_database(template_db, db_name)
            else:
                db.exp_create_database(db_name, demo, lang)

        finally:
            if test_enable:
                tools.config["test_enable"] = test_enable
示例#5
0
    def _create_db(self, template_db, db_name, demo, lang='en_US'):
        """Synchronous db creation"""
        if not self:
            return
        elif self.type != 'local':
            raise NotImplementedError()

        # to avoid installing extra modules we need this condition
        if tools.config['init']:
            tools.config['init'] = {}

        test_enable = tools.config['test_enable']
        if test_enable:
            tools.config['test_enable'] = {}

        # we don't need tests in templates and builds
        with turn_off_tests():
            if template_db:
                db._drop_conn(self.env.cr, template_db)
                db.exp_duplicate_database(template_db, db_name)
            else:
                db.exp_create_database(db_name, demo, lang)
示例#6
0
 def crear_database(self):
     self.state = 'creating'
     db.exp_create_database(db_name=self.name,
                            demo=False,
                            lang='es_PE',
                            user_password=self.password)