server-tools/module_auto_update
Jairo Llopis f02d14a343 [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.
2020-05-18 13:10:47 +02:00
..
data [REF] module_auto_update: Step 3, backwards compatibility 2020-05-18 13:10:47 +02:00
i18n OCA Transbot updated translations from Transifex 2020-05-18 13:10:47 +02:00
migrations/10.0.2.0.0 [FIX] module_auto_update: Rollback cursor if param exists 2020-05-18 13:10:47 +02:00
models [FIX] Forward port module_auto_update refactoring from 9.0 2020-05-18 13:10:47 +02:00
tests [FIX] Forward port module_auto_update refactoring from 9.0 2020-05-18 13:10:47 +02:00
wizards [REF] module_auto_update: Step 3, backwards compatibility 2020-05-18 13:10:47 +02:00
README.rst [REF] module_auto_update: Step 3, backwards compatibility 2020-05-18 13:10:47 +02:00
__init__.py [REF] module_auto_update: Step 3, backwards compatibility 2020-05-18 13:10:47 +02:00
__manifest__.py [REF] module_auto_update: Step 3, backwards compatibility 2020-05-18 13:10:47 +02:00
addon_hash.py [REF] module_auto_update: Step 2, add new API 2020-05-18 13:10:47 +02:00
hooks.py [REF] module_auto_update: Step 3, backwards compatibility 2020-05-18 13:10:47 +02:00

README.rst

.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg
   :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
   :alt: License: LGPL-3

==================
Module Auto Update
==================

This addon provides mechanisms to compute sha1 hashes of installed addons,
and save them in the database. It also provides a method that exploits these
mechanisms to update a database by upgrading only the modules for which the
hash has changed since the last successful upgrade.

Configuration
=============

This module supports the following system parameters:

* ``module_auto_update.exclude_patterns``: comma-separated list of file
  name patterns to ignore when computing addon checksums. Defaults to
  ``*.pyc,*.pyo,i18n/*.pot,i18n_extra/*.pot,static/*``.
  Filename patterns must be compatible with the python ``fnmatch`` function.

In addition to the above pattern, .po files corresponding to languages that
are not installed in the Odoo database are ignored when computing checksums.

Usage
=====

The main method provided by this module is ``upgrade_changed_checksum``
on ``ir.module.module``. It runs a database upgrade for all installed
modules for which the hash has changed since the last successful
run of this method. On success it saves the hashes in the database.

The first time this method is invoked after installing the module, it
runs an upgrade of all modules, because it has not saved the hashes yet.
This is by design, priviledging safety. Should this be an issue,
the method ``_save_installed_checksums`` can be invoked in a situation
where one is sure all modules on disk are installed and up-to-date in the
database.

An easy way to invoke this upgrade mechanism is by issuing the following
in an Odoo shell session::

  env['ir.module.module'].upgrade_changed_checksum()

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
   :alt: Try me on Runbot
   :target: https://runbot.odoo-community.org/runbot/149/11.0

Known issues / Roadmap
======================

* Since version ``2.0.0``, some features have been deprecated.
  When you upgrade from previous versions, these features will be kept for
  backwards compatibility, but beware! They are buggy!

  If you install this addon from scratch, these features are disabled by
  default.

  To force enabling or disabling the deprecated features, set a configuration
  parameter called ``module_auto_update.enable_deprecated`` to either ``1``
  or ``0``. It is recommended that you disable them.

  Keep in mind that from this version, all upgrades are assumed to run in a
  separate odoo instance, dedicated exclusively to upgrade Odoo.

* When migrating the addon to new versions, the deprecated features should be
  removed. To make it simple all deprecated features are found in files
  suffixed with ``_deprecated``.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/server-tools/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.

Credits
=======

Images
------

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

Contributors
------------

* Brent Hughes <brent.hughes@laslabs.com>
* Juan José Scarafía <jjs@adhoc.com.ar>
* Jairo Llopis <jairo.llopis@tecnativa.com>
* Stéphane Bidoul <stephane.bidoul@acsone.eu> (https://acsone.eu)

Do not contact contributors directly about support or help with technical issues.

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
   :alt: Odoo Community Association
   :target: https://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

To contribute to this module, please visit https://odoo-community.org.