예제 #1
0
def new_dump_db(db_name, stream, backup_format='zip', anonymized=True):
    if anonymized:
        with Registry.new(db_name).cursor() as cr:
            env = api.Environment(cr, SUPERUSER_ID, {})
            anon_query = env['ir.model.fields'].get_anonymization_query()
        if not anon_query:
            db._logger.info("No data to anonymize in database `%s`.", db_name)
        else:
            db._logger.info('Anonymize and dump database `%s`.', db_name)
            anon_db_name = '%s_anon_%s' % (db_name,
                                           time.strftime('%Y%m%d_%H%M%S'))
            db.exp_duplicate_database(db_name, anon_db_name)
            try:
                if backup_format == 'zip':
                    # To avoid to archive filestore
                    # with non-anonymized attachments
                    anon_fs = tools.config.filestore(anon_db_name)
                    shutil.rmtree(anon_fs, ignore_errors=True)
                with Registry.new(anon_db_name).cursor() as cr:
                    db._logger.info('ANONYMIZE DB: %s', anon_db_name)
                    cr.execute(anon_query)
            except Exception:
                db.exp_drop(anon_db_name)
            return NewDbDump(anon_db_name, stream, backup_format)
    return native_dump_db(db_name, stream, backup_format)
예제 #2
0
 def install_modules(self):
     """Set all selected modules and actually install them."""
     self.ensure_one()
     self.module_ids.write({"state": "to install"})
     self.env.cr.commit()  # pylint: disable=invalid-commit
     Registry.new(self.env.cr.dbname, update_module=True)
     self.write({"state": "done"})
     return self.return_same_form_view()
예제 #3
0
    def test_02_uninstall(self):
        """ Check a few things showing the module is uninstalled. """
        with environment() as env:
            module = env['ir.module.module'].search([('name', '=', MODULE)])
            assert len(module) == 1
            module.button_uninstall()
        Registry.new(common.get_db_name(), update_module=True)

        with environment() as env:
            self.assertNotIn('test_uninstall.model', env.registry)
            self.assertFalse(env['ir.model.data'].search([('module', '=', MODULE)]))
            self.assertFalse(env['ir.model.fields'].search([('model', '=', MODEL)]))
예제 #4
0
    def test_01_install(self):
        """ Check a few things showing the module is installed. """
        with environment() as env:
            module = env["ir.module.module"].search([("name", "=", MODULE)])
            assert len(module) == 1
            module.button_install()
        Registry.new(common.get_db_name(), update_module=True)

        with environment() as env:
            self.assertIn("test_uninstall.model", env.registry)
            self.assertTrue(env["ir.model.data"].search([("module", "=", MODULE)]))
            self.assertTrue(env["ir.model.fields"].search([("model", "=", MODEL)]))
예제 #5
0
    def generate(self):
        """ Main wizard step. Make sure that all modules are up-to-date,
        then reinitialize all installed modules.
        Equivalent of running the server with '-d <database> --init all'

        The goal of this is to fill the records table.

        TODO: update module list and versions, then update all modules? """
        # Truncate the records table
        if (openupgrade_tools.table_exists(
            self.env.cr, 'openupgrade_attribute') and
                openupgrade_tools.table_exists(
                    self.env.cr, 'openupgrade_record')):
            self.env.cr.execute(
                'TRUNCATE openupgrade_attribute, openupgrade_record;'
                )

        # Need to get all modules in state 'installed'
        modules = self.env['ir.module.module'].search(
            [('state', 'in', ['to install', 'to upgrade'])])
        if modules:
            self.env.cr.commit()
            Registry.new(self.env.cr.dbname, update_module=True)
        # Did we succeed above?
        modules = self.env['ir.module.module'].search(
            [('state', 'in', ['to install', 'to upgrade'])])
        if modules:
            raise UserError(
                "Cannot seem to install or upgrade modules %s" % (
                    ', '.join([module.name for module in modules])))
        # Now reinitialize all installed modules
        self.env['ir.module.module'].search(
            [('state', '=', 'installed')]).write(
                {'state': 'to install'})
        self.env.cr.commit()
        Registry.new(self.env.cr.dbname, update_module=True)

        # Set noupdate property from ir_model_data
        self.env.cr.execute(
            """ UPDATE openupgrade_record our
            SET noupdate = imd.noupdate
            FROM ir_model_data imd
            WHERE our.type = 'xmlid'
                AND our.model = imd.model
                AND our.name = imd.module || '.' || imd.name
            """)
        self.env.invalidate([
            (self.env['openupgrade.record']._fields['noupdate'], None),
        ])
        return self.write({'state': 'ready'})
 def install_all(self):
     """ Main wizard step. Set all installable modules to install
     and actually install them. Exclude testing modules. """
     modules = self.env['ir.module.module'].search([
         ('state', 'not in', ['installed', 'uninstallable', 'unknown']),
         ('category_id.name', '!=', 'Tests'),
         ('name', 'not in', BLACKLIST_MODULES),
     ])
     if modules:
         modules.write({'state': 'to install'})
         self.env.cr.commit()
         Registry.new(self.env.cr.dbname, update_module=True)
         self.write({'state': 'ready'})
     return True
 def __enter__(self):
     """
     Context enter function.
     Temporarily add odoo 10 server path to system path and pop afterwards.
     Import odoo 10 server from path as library.
     Init logger, registry and environment.
     Add addons path to config.
     :returns Odoo10Context: This instance
     """
     sys.path.append(self.server_path)
     from odoo import netsvc, api
     from odoo.modules.registry import Registry
     from odoo.tools import trans_export, config, trans_load_data
     self.trans_export = trans_export
     self.trans_load_data = trans_load_data
     sys.path.pop()
     netsvc.init_logger()
     config['addons_path'] = (
         config.get('addons_path') + ',' + self.addons_path
     )
     registry = Registry.new(self.dbname)
     self.environment_manage = api.Environment.manage()
     self.environment_manage.__enter__()
     self.cr = registry.cursor()
     return self
예제 #8
0
 def __enter__(self):
     """
     Context enter function.
     Temporarily add odoo 10 server path to system path and pop afterwards.
     Import odoo 10 server from path as library.
     Init logger, registry and environment.
     Add addons path to config.
     :returns Odoo10Context: This instance
     """
     sys.path.append(self.server_path)
     from odoo import netsvc, api
     from odoo.modules.registry import Registry
     from odoo.tools import trans_export, config, trans_load_data
     self.trans_export = trans_export
     self.trans_load_data = trans_load_data
     sys.path.pop()
     netsvc.init_logger()
     config['addons_path'] = (
         config.get('addons_path') + ',' + self.addons_path
     )
     registry = Registry.new(self.dbname)
     self.environment_manage = api.Environment.manage()
     self.environment_manage.__enter__()
     self.cr = registry.cursor()
     return self
예제 #9
0
 def _update_registry(self):
     """ Update the registry after a modification on action rules. """
     if self.env.registry.ready:
         # for the sake of simplicity, simply force the registry to reload
         self._cr.commit()
         self.env.reset()
         registry = Registry.new(self._cr.dbname)
         registry.signal_registry_change()
예제 #10
0
 def _update_registry(self):
     """ Update the registry after a modification on action rules. """
     if self.env.registry.ready and not self.env.context.get('import_file'):
         # for the sake of simplicity, simply force the registry to reload
         self._cr.commit()
         self.env.reset()
         registry = Registry.new(self._cr.dbname)
         registry.registry_invalidated = True
예제 #11
0
 def _update_registry(self):
     """ Update the registry after a modification on action rules. """
     if self.env.registry.ready:
         # for the sake of simplicity, simply force the registry to reload
         self._cr.commit()
         self.env.reset()
         registry = Registry.new(self._cr.dbname)
         registry.signal_registry_change()
예제 #12
0
 def _update_registry(self):
     """ Update the registry after a modification on action rules. """
     if self.env.registry.ready and not self.env.context.get('import_file'):
         # for the sake of simplicity, simply force the registry to reload
         self._cr.commit()
         self.env.reset()
         registry = Registry.new(self._cr.dbname)
         registry.registry_invalidated = True
예제 #13
0
def export(ctx, language, db_name, module, fix):
    modules = module or ['all']

    from odoo.modules.registry import Registry
    from odooku.api import environment
    from odoo.tools import trans_export

    with tempfile.TemporaryFile() as t:

        # Perform checks (and possible fixes)
        registry = Registry(db_name)
        with registry.cursor() as cr:
            with environment(cr) as env:
                lang = env['res.lang'].with_context(
                    dict(active_test=False)).search([('code', '=', language)])
                if not lang:
                    raise ValueError("Language %s does not exist" % language)
                if not lang[0].active:
                    if not fix:
                        raise ValueError("Language %s is not activated" %
                                         language)
                    else:
                        installed = env['ir.module.module'].search([
                            ('state', '=', 'installed')
                        ])
                        installed._update_translations(language)

                if module:
                    installed = env['ir.module.module'].search([
                        ('name', 'in', module), ('state', '=', 'installed')
                    ])
                    missing = set(module) - set(
                        [mod.name for mod in installed])
                    if missing:
                        if not fix:
                            raise ValueError("Modules '%s' are not installed" %
                                             ", ".join(missing))
                        else:
                            ctx.obj['config']['init'] = {
                                module_name: 1
                                for module_name in module
                            }

        # Export
        registry = Registry.new(db_name, update_module=fix)
        with registry.cursor() as cr:
            with environment(cr) as env:
                trans_export(language, modules, t, 'po', cr)

        t.seek(0)
        # Pipe to stdout
        while True:
            chunk = t.read(CHUNK_SIZE)
            if not chunk:
                break
            sys.stdout.buffer.write(chunk)
예제 #14
0
def preload(ctx, db_name, module, demo_data):
    config = (ctx.obj['config'])

    from odoo.modules.registry import Registry

    if module:
        modules = {module_name: 1 for module_name in module}
        config['init'] = dict(modules)

    registry = Registry.new(db_name, force_demo=demo_data, update_module=True)
예제 #15
0
def update(ctx, db_name, module, init):
    config = (ctx.obj['config'])

    from odoo.modules.registry import Registry
    config['init' if init else 'update'] = {
        module_name: 1
        for module_name in module or ['all']
    }

    for db in db_name:
        registry = Registry.new(db, update_module=True)
    def generate(self):
        """ Main wizard step. Make sure that all modules are up-to-date,
        then reinitialize all installed modules.
        Equivalent of running the server with '-d <database> --init all'

        The goal of this is to fill the records table.

        TODO: update module list and versions, then update all modules? """
        # Truncate the records table
        if (openupgrade_tools.table_exists(self.env.cr,
                                           'openupgrade_attribute')
                and openupgrade_tools.table_exists(self.env.cr,
                                                   'openupgrade_record')):
            self.env.cr.execute(
                'TRUNCATE openupgrade_attribute, openupgrade_record;')

        # Need to get all modules in state 'installed'
        modules = self.env['ir.module.module'].search([
            ('state', 'in', ['to install', 'to upgrade'])
        ])
        if modules:
            self.env.cr.commit()
            Registry.new(self.env.cr.dbname, update_module=True)
        # Did we succeed above?
        modules = self.env['ir.module.module'].search([
            ('state', 'in', ['to install', 'to upgrade'])
        ])
        if modules:
            raise UserError("Cannot seem to install or upgrade modules %s" %
                            (', '.join([module.name for module in modules])))
        # Now reinitialize all installed modules
        self.env['ir.module.module'].search([('state', '=', 'installed')
                                             ]).write({'state': 'to install'})
        self.env.cr.commit()
        Registry.new(self.env.cr.dbname, update_module=True)
        return self.write({'state': 'ready'})
예제 #17
0
 def begin_test_model(self):
     module_name1 = 'product_extend'
     dbname = 'user01'
     test_enable_val = odoo.tools.config['test_enable']
     if not test_enable_val:
         odoo.tools.config['test_enable'] = True
         if not odoo.tools.config['init']:
             odoo.tools.config['init'] = {module_name1: 1}
             test_result = Registry.new(db_name=dbname,
                                        force_demo=False,
                                        status=None,
                                        update_module={module_name1: 1})
             print odoo.tools.config['init']
             print 'haha', self.module_name
         odoo.tools.config['test_enable'] = False
     else:
         if not odoo.tools.config['init']:
             odoo.tools.config['init'] = {module_name1: 1}
             test_result = Registry.new(db_name=dbname,
                                        force_demo=False,
                                        status=None,
                                        update_module={module_name1: 1})
             print odoo.tools.config['init']
         print 'hehe'
예제 #18
0
def preload_registries(dbnames):
    """ Preload a registries, possibly run a test file."""
    # TODO: move all config checks to args dont check tools.config here
    dbnames = dbnames or []
    rc = 0
    for dbname in dbnames:
        try:
            update_module = config['init'] or config['update']
            registry = Registry.new(dbname, update_module=update_module)

            # run test_file if provided
            if config['test_file']:
                test_file = config['test_file']
                if not os.path.isfile(test_file):
                    _logger.warning('test file %s cannot be found', test_file)
                elif not test_file.endswith('py'):
                    _logger.warning('test file %s is not a python file',
                                    test_file)
                else:
                    _logger.info('loading test file %s', test_file)
                    with odoo.api.Environment.manage():
                        load_test_file_py(registry, test_file)

            # run post-install tests
            if config['test_enable']:
                t0 = time.time()
                t0_sql = odoo.sql_db.sql_counter
                module_names = (registry.updated_modules
                                if update_module else registry._init_modules)
                _logger.info("Starting post tests")
                with odoo.api.Environment.manage():
                    for module_name in module_names:
                        result = run_unit_tests(module_name,
                                                registry.db_name,
                                                position='post_install')
                        registry._assertion_report.record_result(result)
                _logger.info("All post-tested in %.2fs, %s queries",
                             time.time() - t0,
                             odoo.sql_db.sql_counter - t0_sql)

            if registry._assertion_report.failures:
                rc += 1
        except Exception:
            _logger.critical('Failed to initialize database `%s`.',
                             dbname,
                             exc_info=True)
            return -1
    return rc
예제 #19
0
    def get_graph(self, module_name):
        dbname = odoo.tools.config['db_name']
        cr = Registry.new(dbname)._db.cursor()
        graph = odoo.modules.graph.Graph()

        states = ['installed', 'to upgrade', 'to remove']
        cr.execute("SELECT name from ir_module_module WHERE state IN %s", (tuple(states),))
        module_list = [name for (name,) in cr.fetchall() if name not in graph]

        graph.add_modules(cr, module_list)
        if module_name is graph:
            graph = graph[module_name]

        deps = {}
        for key, value in graph.iteritems():
            deps[key] = value.info['depends']

        return json.dumps(deps)
예제 #20
0
    def get_model_graph(self):
        dbname = odoo.tools.config['db_name']
        cr = Registry.new(dbname)._db.cursor()
        graph = odoo.modules.graph.Graph()

        cr.execute("SELECT distinct(model) from ir_model_fields")
        model_list = [model for (model,) in cr.fetchall()]

        deps = {}
        for model in model_list:
            print(model)
            cr.execute("SELECT name, ttype, relation from ir_model_fields where model = %s order by name", (model,))
            fields_list = [(name, ttype, relation) for (name, ttype, relation,) in cr.fetchall()]

            label = '<b>' + model.upper() + '</b>'
            depends = []
            for field in fields_list:
                field_name = field[0]
                field_type = field[1]
                relation = field[2]
                if field_name in ['id', 'create_uid', 'create_date', 'write_uid', 'write_date', '__last_update']:
                    continue

                if field_name.startswith('message_'):
                    continue

                if model not in ['res.partner', 'res.users']:
                    label += '\n{name} ({type})'.format(name=field_name, type=field_type)

                    if relation and relation != model:
                        print(model + '=>' + relation)
                        depends.append(relation)

            if model in ['res.partner', 'res.users']:
                label += '\n[...]'

            deps.update({
                model: {
                    'label': label,
                    'depends': depends,
                }
            })

        return json.dumps(deps)
예제 #21
0
    def get_graph(self, module_name):
        dbname = odoo.tools.config['db_name']
        cr = Registry.new(dbname)._db.cursor()
        graph = odoo.modules.graph.Graph()

        cr.execute("SELECT name from ir_module_module")
        module_list = [name for (name,) in cr.fetchall() if name not in graph]

        graph.add_modules(cr, module_list)
        if module_name is graph:
            graph = graph[module_name]

        deps = {}
        for key, value in graph.iteritems():
            deps[key] = {
                'depends': value.info['depends'],
                'state': value.state,
            }

        return json.dumps(deps)
예제 #22
0
    def _send_simplified_to_sii(self):
        for order in self.filtered(lambda i: i.state in ['done', 'paid']):
            wsdl = self.env['ir.config_parameter'].get_param(
                'l10n_es_aeat_sii.wsdl_out', False)
            port_name = 'SuministroFactEmitidas'
            if not order.sii_sent:
                tipo_comunicacion = 'A0'
            else:
                tipo_comunicacion = 'A1'
            header = order._get_header(tipo_comunicacion)
            try:
                orders = order._get_simplified()
            except Exception as fault:
                new_cr = Registry.new(self.env.cr.dbname).cursor()
                env = api.Environment(new_cr, self.env.uid, self.env.context)
                self.with_env(env).sii_send_error = fault
                new_cr.commit()
                new_cr.close()
                raise

            try:
                serv = order._connect_wsdl(wsdl, port_name)
                res = serv.SuministroLRFacturasEmitidas(header, orders)
                if res['EstadoEnvio'] in ['Correcto', 'ParcialmenteCorrecto']:
                    self.sii_sent = True
                    self.sii_csv = res['CSV']
                else:
                    self.sii_sent = False
                self.env['aeat.sii.result'].create_result(
                    order, res, 'normal', False, 'pos.order')
                send_error = False
                res_line = res['RespuestaLinea'][0]
                if res_line['CodigoErrorRegistro']:
                    send_error = u"{} | {}".format(
                        unicode(res_line['CodigoErrorRegistro']),
                        unicode(res_line['DescripcionErrorRegistro'])[:60])
                self.sii_send_error = send_error
            except Exception as fault:
                self.env['aeat.sii.result'].create_result(
                    order, False, 'normal', fault, 'pos.order')
                self.sii_send_error = fault
예제 #23
0
    def create(self, vals):
        if self._context and self._context.get('bve'):
            vals['state'] = 'base'
        res = super(IrModel, self).create(vals)

        # this sql update is necessary since a write method here would
        # be not working (an orm constraint is restricting the modification
        # of the state field while updating ir.model)
        q = "UPDATE ir_model SET state = 'manual' WHERE id = %s"
        self.env.cr.execute(q, (res.id, ))

        # # update registry
        if self._context.get('bve'):
            # setup models; this reloads custom models in registry
            self.pool.setup_models(self._cr, partial=(not self.pool.ready))

            # signal that registry has changed
            registry = Registry.new(self._cr.dbname)
            registry.signal_registry_change()

        return res
예제 #24
0
파일: server.py 프로젝트: befks/odoo
def preload_registries(dbnames):
    """ Preload a registries, possibly run a test file."""
    # TODO: move all config checks to args dont check tools.config here
    dbnames = dbnames or []
    rc = 0
    for dbname in dbnames:
        try:
            update_module = config['init'] or config['update']
            registry = Registry.new(dbname, update_module=update_module)

            # run test_file if provided
            if config['test_file']:
                test_file = config['test_file']
                _logger.info('loading test file %s', test_file)
                with odoo.api.Environment.manage():
                    if test_file.endswith('yml'):
                        load_test_file_yml(registry, test_file)
                    elif test_file.endswith('py'):
                        load_test_file_py(registry, test_file)

            # run post-install tests
            if config['test_enable']:
                t0 = time.time()
                t0_sql = odoo.sql_db.sql_counter
                module_names = (registry.updated_modules if update_module else
                                registry._init_modules)
                with odoo.api.Environment.manage():
                    for module_name in module_names:
                        result = run_unit_tests(module_name, registry.db_name,
                                                position=runs_post_install)
                        registry._assertion_report.record_result(result)
                _logger.info("All post-tested in %.2fs, %s queries",
                             time.time() - t0, odoo.sql_db.sql_counter - t0_sql)

            if registry._assertion_report.failures:
                rc += 1
        except Exception:
            _logger.critical('Failed to initialize database `%s`.', dbname, exc_info=True)
            return -1
    return rc
예제 #25
0
    def generate(self):
        """Reinitialize all installed modules.
        Equivalent of running the server with '-d <database> --init all'

        The goal of this is to fill the records table.

        TODO: update module list and versions, then update all modules?"""

        # Truncate the records table
        self.env.cr.execute("TRUNCATE upgrade_attribute, upgrade_record;")

        # Check of all the modules are correctly installed
        modules = self.env["ir.module.module"].search([
            ("state", "in", ["to install", "to upgrade"])
        ])
        if modules:
            raise UserError(
                _("Cannot seem to install or upgrade modules %s") %
                (", ".join([module.name for module in modules])))
        # Now reinitialize all installed modules
        self.env["ir.module.module"].search([("state", "=", "installed")
                                             ]).write({"state": "to install"})
        self.env.cr.commit()  # pylint: disable=invalid-commit

        # Patch the registry on the thread
        thread = current_thread()
        thread._upgrade_registry = {}

        # Regenerate the registry with monkeypatches that log the records
        with OdooPatch():
            Registry.new(self.env.cr.dbname, update_module=True)

        # Free the registry
        delattr(thread, "_upgrade_registry")

        # Set domain property
        self.env.cr.execute(""" UPDATE upgrade_record our
            SET domain = iaw.domain
            FROM ir_model_data imd
            JOIN ir_act_window iaw ON imd.res_id = iaw.id
            WHERE our.type = 'xmlid'
                AND imd.model = 'ir.actions.act_window'
                AND our.model = imd.model
                AND our.name = imd.module || '.' || imd.name
            """)
        self.env.cache.invalidate([
            (self.env["upgrade.record"]._fields["domain"], None),
        ])

        # Set noupdate property from ir_model_data
        self.env.cr.execute(""" UPDATE upgrade_record our
            SET noupdate = imd.noupdate
            FROM ir_model_data imd
            WHERE our.type = 'xmlid'
                AND our.model = imd.model
                AND our.name = imd.module || '.' || imd.name
            """)
        self.env.cache.invalidate([
            (self.env["upgrade.record"]._fields["noupdate"], None),
        ])

        # Log model records
        self.env.cr.execute(
            """INSERT INTO upgrade_record
            (create_date, module, name, model, type)
            SELECT NOW() AT TIME ZONE 'UTC',
                imd2.module, imd2.module || '.' || imd.name AS name,
                im.model, 'model' AS type
            FROM (
                SELECT min(id) as id, name, res_id
                FROM ir_model_data
                WHERE name LIKE 'model_%' AND model = 'ir.model'
                GROUP BY name, res_id
                ) imd
            JOIN ir_model_data imd2 ON imd2.id = imd.id
            JOIN ir_model im ON imd.res_id = im.id
            ORDER BY imd.name, imd.id""", )

        return self.write({"state": "done"})
예제 #26
0
 def runtests():
     registry = Registry.new(db_name)
     total = (registry._assertion_report.successes + registry._assertion_report.failures)
     failures = registry._assertion_report.failures
     logger.info("Completed (%s) tests. %s failures." % (total, failures))
     sys.exit(1 if failures else 0)
예제 #27
0
    def generate(self):
        """ Main wizard step. Make sure that all modules are up-to-date,
        then reinitialize all installed modules.
        Equivalent of running the server with '-d <database> --init all'

        The goal of this is to fill the records table.

        TODO: update module list and versions, then update all modules? """
        # Truncate the records table
        if (openupgrade_tools.table_exists(self.env.cr,
                                           'openupgrade_attribute')
                and openupgrade_tools.table_exists(self.env.cr,
                                                   'openupgrade_record')):
            self.env.cr.execute(
                'TRUNCATE openupgrade_attribute, openupgrade_record;')

        # Run any quirks
        self.quirk_standard_calendar_attendances()

        # Need to get all modules in state 'installed'
        modules = self.env['ir.module.module'].search([
            ('state', 'in', ['to install', 'to upgrade'])
        ])
        if modules:
            self.env.cr.commit()
            Registry.new(self.env.cr.dbname, update_module=True)
        # Did we succeed above?
        modules = self.env['ir.module.module'].search([
            ('state', 'in', ['to install', 'to upgrade'])
        ])
        if modules:
            raise UserError("Cannot seem to install or upgrade modules %s" %
                            (', '.join([module.name for module in modules])))
        # Now reinitialize all installed modules
        self.env['ir.module.module'].search([('state', '=', 'installed')
                                             ]).write({'state': 'to install'})
        self.env.cr.commit()
        Registry.new(self.env.cr.dbname, update_module=True)

        # Set domain property
        self.env.cr.execute(""" UPDATE openupgrade_record our
            SET domain = iaw.domain
            FROM ir_model_data imd
            JOIN ir_act_window iaw ON imd.res_id = iaw.id
            WHERE our.type = 'xmlid'
                AND imd.model = 'ir.actions.act_window'
                AND our.model = imd.model
                AND our.name = imd.module || '.' || imd.name
            """)
        self.env.cache.invalidate([
            (self.env['openupgrade.record']._fields['domain'], None),
        ])

        # Set noupdate property from ir_model_data
        self.env.cr.execute(""" UPDATE openupgrade_record our
            SET noupdate = imd.noupdate
            FROM ir_model_data imd
            WHERE our.type = 'xmlid'
                AND our.model = imd.model
                AND our.name = imd.module || '.' || imd.name
            """)
        self.env.cache.invalidate([
            (self.env['openupgrade.record']._fields['noupdate'], None),
        ])

        # Log model records
        self.env.cr.execute(
            """INSERT INTO openupgrade_record
            (module, name, model, type)
            SELECT imd2.module, imd2.module || '.' || imd.name AS name,
                im.model, 'model' AS type
            FROM (
                SELECT min(id) as id, name, res_id
                FROM ir_model_data
                WHERE name LIKE 'model_%' AND model = 'ir.model'
                GROUP BY name, res_id
                ) imd
            JOIN ir_model_data imd2 ON imd2.id = imd.id
            JOIN ir_model im ON imd.res_id = im.id
            ORDER BY imd.name, imd.id""", )

        return self.write({'state': 'ready'})