Example #1
0
 def enclose_openerp_api(self, options):
     init = options.init and dict.fromkeys(options.init.split(','), 1) or {}
     update = options.update and dict.fromkeys(options.update.split(','), 1) or {}
     need_env = not options.fast and not init and not update
     if not need_env:
         yield
     else:
         with purplespade.openerp_env(
             db_name=options.database,
             without_demo=options.without_demo,
             init=init,
             update=update
         ):
             yield
    def run(self, args):
        options = self.parse_args(args)
        if options.scratch:
            purplespade.drop_database(options.database)

        actions = {
            'to remove': self._to_remove,
            'to install': self._to_install,
            'to upgrade': self._to_upgrade
        }
        with purplespade.openerp_env(
            db_name=options.database,
            without_demo=options.without_demo,
        ) as env:
            modules = self.get_modules(env)
            builder = api.ActionPlanBuilder(
                system=self.get_module_information(env, modules),
                expected=self.get_expected_configuration(options.conffile),
            )
            action_plan = builder.build()
            for action in action_plan:
                actions[action.action](modules[action.name])
                env.cr.commit()
                env.clear()