Commit Graph

3 Commits (483d52b08050b1997dd216d0f3ec778a69b61d52)

Author SHA1 Message Date
Jairo Llopis 386633d339 [FIX] module_auto_update: Rollback cursor if param exists
Without this patch, when upgrading after you have stored the deprecated features parameter, the cursor became broken and no more migrations could happen. You got this error:

    Traceback (most recent call last):
    File "/usr/local/bin/odoo", line 6, in <module>
        exec(compile(open(__file__).read(), __file__, 'exec'))
    File "/opt/odoo/custom/src/odoo/odoo.py", line 160, in <module>
        main()
    File "/opt/odoo/custom/src/odoo/odoo.py", line 157, in main
        openerp.cli.main()
    File "/opt/odoo/custom/src/odoo/openerp/cli/command.py", line 64, in main
        o.run(args)
    File "/opt/odoo/custom/src/odoo/openerp/cli/shell.py", line 65, in run
        self.shell(openerp.tools.config['db_name'])
    File "/opt/odoo/custom/src/odoo/openerp/cli/shell.py", line 52, in shell
        registry = openerp.modules.registry.RegistryManager.get(dbname)
    File "/opt/odoo/custom/src/odoo/openerp/modules/registry.py", line 355, in get
        update_module)
    File "/opt/odoo/custom/src/odoo/openerp/modules/registry.py", line 386, in new
        openerp.modules.load_modules(registry._db, force_demo, status, update_module)
    File "/opt/odoo/custom/src/odoo/openerp/modules/loading.py", line 335, in load_modules
        force, status, report, loaded_modules, update_module)
    File "/opt/odoo/custom/src/odoo/openerp/modules/loading.py", line 239, in load_marked_modules
        loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
    File "/opt/odoo/custom/src/odoo/openerp/modules/loading.py", line 136, in load_module_graph
        registry.setup_models(cr, partial=True)
    File "/opt/odoo/custom/src/odoo/openerp/modules/registry.py", line 186, in setup_models
        cr.execute('select model, transient from ir_model where state=%s', ('manual',))
    File "/opt/odoo/custom/src/odoo/openerp/sql_db.py", line 154, in wrapper
        return f(self, *args, **kwargs)
    File "/opt/odoo/custom/src/odoo/openerp/sql_db.py", line 233, in execute
        res = self._obj.execute(query, params)
    psycopg2.InternalError: current transaction is aborted, commands ignored until end of transaction block

Now you can safely migrate, be that parameter pre-created or not.
2021-12-27 16:49:36 +02:00
Laurent Mignon (ACSONE) 0c1395a3d8 [FIX] Forward port module_auto_update refactoring from 9.0 2021-12-27 16:49:36 +02:00
Jairo Llopis 3f81cc8906 [REF] module_auto_update: Step 3, backwards compatibility
The previous implementation of this addon proved being extremely buggy:

- It supplied out of the box a enabled cron to update Odoo that didn't restart the server, which possibly meant that upgrades broke things.
- It overloaded standard Odoo upgrade methods that made i.e. installing an addon sometimes forced to upgrade all other addons in the database.
- The checksum system wasn't smart enough, and some files that didn't need a module upgrade triggered the upgrade.
- It was based on a dirhash library that was untested.
- Some updates were not detected properly.
- Storing a column into `ir.module.module` sometimes forbids uninstalling the addon.

Thanks to Stéphane Bidoul (ACSONE), now we have new methods to perform the same work in a safer and more stable way.

All I'm doing here is:

- Cron is disabled by default.
- Installed checksums are no longer saved at first install.
- Old installations should keep most functionality intact thanks to the migration script.
- Drop some duplicated tests.
- Allow module uninstallation by pre-removing the fields from ir.mode.model.
- When uninstalling the addon, the deprecated features will get removed for next installs always.

Besides that, fixes for the new implementation too:

- When uninstalling the addon, we remove the stored checksum data, so further installations work as if the addon was installed from scratch.
2021-12-27 16:49:36 +02:00