Esempio n. 1
0
    def setUp(self):
        super().setUp()
        self._user = self.env['res.users'].create({
            'name': "Bylan",
            'login': '******',
            'password': '******',
            'tz': 'Australia/Eucla',
        })

        # needs a fake request in order to call methods protected with check_identity
        fake_req = DotDict({
            # various things go and access request items
            'httprequest':
            DotDict({
                'environ': {
                    'REMOTE_ADDR': 'localhost'
                },
                'cookies': {},
            }),
            # bypass check_identity flow
            'session': {
                'identity-check-last': time.time()
            }
        })
        _request_stack.push(fake_req)
        self.addCleanup(_request_stack.pop)
Esempio n. 2
0
    def _install_modules(self, db_name, modules):
        if self.type != 'local':
            raise NotImplementedError()

        db = sql_db.db_connect(db_name)
        with api.Environment.manage(), db.cursor() as cr:
            env = api.Environment(cr, SUPERUSER_ID, {})

            # Set odoo.http.request to None.
            #
            # Odoo tries to use its values in translation system, which may eventually
            # change currentThread().dbname to saas master value.
            _request_stack.push(None)

            module_ids = env['ir.module.module'].search([('state', '=',
                                                          'uninstalled')] +
                                                        modules)
            with turn_off_tests():
                module_ids.button_immediate_install()

            # Some magic to force reloading registry in other workers
            env.registry.registry_invalidated = True
            env.registry.signal_changes()

            # return request back
            _request_stack.pop()
Esempio n. 3
0
    def install_modules(self, template_id, template_operator_id):
        self.ensure_one()
        modules = [module.name for module in template_id.template_module_ids]
        modules = [('name', 'in', MANDATORY_MODULES + modules)]
        if self.type == 'local':
            db = sql_db.db_connect(template_operator_id.operator_db_name)
            with api.Environment.manage(), db.cursor() as cr:
                env = api.Environment(cr, SUPERUSER_ID, {})

                # Set odoo.http.request to None.
                #
                # Odoo tries to use its values in translation system, which may eventually
                # change currentThread().dbname to saas master value.
                _request_stack.push(None)

                module_ids = env['ir.module.module'].search([('state', '=',
                                                              'uninstalled')] +
                                                            modules)
                module_ids.button_immediate_install()

                # Some magic to force reloading registry in other workers
                env.registry.registry_invalidated = True
                env.registry.signal_changes()

                # return request back
                _request_stack.pop()

            template_operator_id.state = 'post_init'
            self.with_delay().post_init(template_id, template_operator_id)
Esempio n. 4
0
 def setUp(self):
     super().setUp()
     # needs a fake request in order to call methods protected with check_identity
     fake_req = DotDict({
         # various things go and access request items
         'httprequest': DotDict({
             'environ': {'REMOTE_ADDR': 'localhost'},
             'cookies': {},
         }),
         # bypass check_identity flow
         'session': {'identity-check-last': time.time()}
     })
     _request_stack.push(fake_req)
     self.addCleanup(_request_stack.pop)