Commit Graph

99 Commits (483d52b08050b1997dd216d0f3ec778a69b61d52)

Author SHA1 Message Date
Stéphane Bidoul (ACSONE) 483d52b080 module_auto_update: bump version 2021-12-27 16:49:36 +02:00
Stéphane Bidoul (ACSONE) 2980351947 module_auto_update: check a post condition 2021-12-27 16:49:36 +02:00
Benjamin Willig 07d7f01f9f [CHG] updated version number 2021-12-27 16:49:36 +02:00
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 d93d9c90bc [FIX] module_auto_update: Add .pyo sample file (#1205)
Without this patch, if your tests are run under a `PYTHONOPTIMIZE=2` precompiled environment, they'd fail with this error because a new `.pyo` file would be created.:

    FAIL: test_basic (openerp.addons.module_auto_update.tests.test_addon_hash.TestAddonHash)
    Traceback (most recent call last):
    `   File "/opt/odoo/auto/addons/module_auto_update/tests/test_addon_hash.py", line 41, in test_basic
    `     'static/src/some.js',
    ` AssertionError: Lists differ: ['README.rst', 'data/f1.xml', ... != ['README.rst', 'data/f1.xml', ...
    `
    ` First differing element 13:
    ` models/stuff.pyo
    ` static/src/some.js
    `
    ` First list contains 1 additional elements.
    ` First extra element 14:
    ` static/src/some.js
    `
    `   ['README.rst',
    `    'data/f1.xml',
    `    'data/f2.xml',
    `    'i18n/en.po',
    `    'i18n/en_US.po',
    `    'i18n/fr.po',
    `    'i18n/fr_BE.po',
    `    'i18n/test.pot',
    `    'i18n_extra/en.po',
    `    'i18n_extra/fr.po',
    `    'i18n_extra/nl_NL.po',
    `    'models/stuff.py',
    `    'models/stuff.pyc',
    ` -  'models/stuff.pyo',
    `    'static/src/some.js']
    Ran 3 tests in 0.005s
    FAILED

With this patch, the `.pyo` file is included, so tests will pass anywhere.
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
Stéphane Bidoul (ACSONE) a1f71e9ad6 [REF] module_auto_update: Step 2, add new API
This code comes from the module_checksum_upgrade proposal
at https://github.com/OCA/server-tools/pull/1176.

* [ADD] module_checksum_upgrade

It provides the core mechanism of module_auto_update without
the cron nor any change to the standard upgrade mechanism.
Instead it provides an API on which module_auto_update can build,
as well as a method which can be called from a script to run
the upgrade of modules for which the checksum has changed.

* [IMP] refactor module_auto_update

Make it depend on module_checksum_upgrade which provides
the core mechanisms of managing the checksums. module_auto_update
makes it automatic.

* [IMP] module_checksum_upgrade: better exclusion mechanism

Ignore files based on exclude patterns.
Ignore uninstalled languages.
Better default for patterns to ignore (*.pyc,*.pyo,*.pot,static/*)

For better control on the hashing mechanism implement our own:
it's quite easy, and the checksumdir module used previously had
no test.

* [MIG] module_auto_update: adapt to new checksum mechanism

* [IMP] module_checksum_upgrade: raise in case of
 incomplete upgrade

* [IMP] module_checksum_upgrade: improve default exclusion
 pattern

* [IMP] module_checksum_upgrade: control translations
 overwrite

* [IMP] module_checksum_upgrade: one more test

* [IMP] module_checksum_upgrade: credits [ci skip]
2021-12-27 16:49:36 +02:00
Jairo Llopis 015c18004d [REF] module_auto_update: Step 1, move all deprecated stuff to deprecated files
- Files are clearly suffixed with `_deprecated` so we know those features have no support nor migrations.
- Views are removed, since updating from UI was too buggy to support it anymore.
2021-12-27 16:49:36 +02:00
OCA Transbot 20f6a9dfb4 OCA Transbot updated translations from Transifex 2021-12-27 16:49:36 +02:00
Jairo Llopis 4f351b283b [MIG] module_auto_update: Migrate to v11 2021-12-27 16:49:36 +02:00
Jairo Llopis a90b06492b [FIX][module_auto_update] Always store changes in lower graphs
The same problem that was fixed for the `base` addon in #948 happened with random addons that do not depend on `module_auto_update` (a.k.a. any addon) that Odoo decided to load before that one in the graph.

Now we always check for all addons if their state has changed, and make sure to trigger the udpate mechanism that stores the right value in `installed_checksum_dir` field.

If you installed and uninstalled the addon right away, you'd get a ProgrammingError saying that some columns exist no more. Checks are done now using `search_read`, which lets us limit the fields being fetched, and the environment is cleared to make sure nothing fails.

Also we now guess if this own addon has been uninstalled and skip further logic if so, given it would hit broken triggers otherwise as it did before.
2021-12-27 16:49:36 +02:00
Jairo Llopis ea9ae22d49 [FIX][module_auto_update] Record base addon checksum (#948) 2021-12-27 16:49:36 +02:00
Dave Lasley 3e868c0448 [FIX] module_auto_update: Don't compute upgrade on uninstall
* `button_uninstall` calls `get_module_list`, which subsequently forces module upgrades. Add a context validation to prevent that
* Add test for button_immediate_uninstall
* Mock commit for immediate uninstall
* Fix immediate uninstall test
* Switch nesting
* Bump module version
2021-12-27 16:49:36 +02:00
Jairo Llopis 2052967605 [REF][module_auto_update] Forward port v9 improvements
* Recompute dir hashes only when needed - By removing the recomputation from `update_list` we get faster CLI module upgrades and it only performs the autoupdate when using the autoupdate wizard or cron.
* Pass tests if addon is in readonly directory
* Set dependencies to upgrade

[FIX][module_auto_update] Pass tests if addon is in readonly directory

[FIX][module_auto_update] Set dependencies to upgrade
2021-12-27 16:49:36 +02:00
OCA Transbot 620eb86f92 OCA Transbot updated translations from Transifex 2021-12-27 16:49:36 +02:00
Brenton Hughes 890d8766e6 [ADD] module_auto_update: Create module (#882)
* [IMP] module_auto_update: Create new module
* Add checksum_dir and checksum_installed fields to ir.module.module
  * Add checksum_dir to compute current checksum of module directory
    in addons path
  * Add checksum_installed to store checksum of module directory
    when module was last installed or upgraded
* Use checksumdir Python library to compute module directory sha1
  hashes, ignoring pyc and pyo extensions
* Extend update_list method to compare modules' checksum_dir and
  checksum_installed, then change state of modules with differing
  checksums to 'to upgrade'
* Replace Apps/Updates menu item with menu item of same name, which
  updates apps list and displays tree view of ir.module.module
  records with state 'to upgrade'
* Extend create and write methods to store computed checksum_dir as
  checksum_installed during module installation and upgrade, and
  set checksum_installed to False on uninstall
* Use context to stop checksum_installed from being updated during
  upgrade/uninstall cancellation
* Add cron job to periodically check for module upgrades by
  comparing checksums, then perform any available upgrades
* Extend upgrade_module method (called by cron and 'Apply Scheduled
  Upgrades' menu item) to call update_list
* Add post_init_hook to store checksum_installed of existing
  modules
* Add test coverage

* [FIX] module_auto_update: Fix test broken by changes
* Use dummy module to test update_list method instead of
  module_auto_update
2021-12-27 16:49:36 +02:00
OCA-git-bot 351e4d88fd [ADD] setup.py 2021-12-20 07:53:42 +00:00
OCA-git-bot 7af8e27e59 [UPD] README.rst 2021-12-20 07:53:41 +00:00
OCA-git-bot 8e8a3ccf29 [UPD] addons table in README.md 2021-12-20 07:53:41 +00:00
oca-ci 857f7467e6 [UPD] Update base_cron_exclusion.pot 2021-12-20 07:51:43 +00:00
OCA-git-bot fb29f3bad3 Merge PR #2225 into 15.0
Signed-off-by LoisRForgeFlow
2021-12-20 07:50:00 +00:00
Christopher Ormaza e1462c6b90 [15.0][MIG] base_cron_exclusion 2021-12-10 11:14:09 -05:00
Christopher Ormaza 416bd03603 [IMP] base_cron_exclusion: black, isort, prettier 2021-12-10 11:11:07 -05:00
OCA-git-bot 276f0ae1a3 [UPD] README.rst 2021-12-10 11:10:38 -05:00
oca-travis 219663316b [UPD] Update base_cron_exclusion.pot 2021-12-10 11:10:38 -05:00
davidborromeo 8cc5a49883 [MIG] base_cron_exclusion: Migration to 14.0 2021-12-10 11:10:38 -05:00
OCA-git-bot 81df75b88a pre-commit update 2021-12-10 11:10:38 -05:00
OCA Transbot 73d11f1487 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: server-tools-13.0/server-tools-13.0-base_cron_exclusion
Translate-URL: https://translation.odoo-community.org/projects/server-tools-13-0/server-tools-13-0-base_cron_exclusion/
2021-12-10 11:10:38 -05:00
OCA-git-bot 5998c6b9ab [UPD] README.rst 2021-12-10 11:10:38 -05:00
oca-travis a459685fb6 [UPD] Update base_cron_exclusion.pot 2021-12-10 11:10:38 -05:00
Lois Rilo 31205e2804 [13.0][MIG] base_cron_exclusion 2021-12-10 11:10:38 -05:00
Lois Rilo 542af12d27 [IMP] base_cron_exclusion: black, isort 2021-12-10 11:10:38 -05:00
黎伟杰 37e9a888f6 Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (3 of 3 strings)

Translation: server-tools-12.0/server-tools-12.0-base_cron_exclusion
Translate-URL: https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-base_cron_exclusion/zh_CN/
2021-12-10 11:10:38 -05:00
黎伟杰 f11b900626 Added translation using Weblate (Chinese (Simplified)) 2021-12-10 11:10:38 -05:00
Lois Rilo fba1203bc6 [12.0] base_cron_exclusion to LGPL
Change license to LGPL to not limit the usage of this module
in private customizations.
2021-12-10 11:10:38 -05:00
OCA-git-bot def2cb2416 [UPD] README.rst 2021-12-10 11:10:38 -05:00
oca-travis ea47d4470b [UPD] Update base_cron_exclusion.pot 2021-12-10 11:10:38 -05:00
hveficent 0ea4a001c1 [MIG] base_cron_exclusion: Migration to 12.0 2021-12-10 11:10:38 -05:00
OCA Transbot 8cd3199c4b OCA Transbot updated translations from Transifex 2021-12-10 11:10:38 -05:00
Lois Rilo aed41bc2b9 [10.0][MIG] base_cron_exclusion (#1105)
* [9.0][ADD] base_cron_exclusion

* [10.0][MIG] base_cron_exclusion

[11.0][MIG] base_cron_exclusion
2021-12-10 11:10:38 -05:00
OCA-git-bot 7821da6df9 [UPD] addons table in README.md 2021-11-15 20:20:14 +00:00
OCA-git-bot d1ec921493 upgrade_analysis 15.0.1.0.2 2021-11-15 20:20:10 +00:00
OCA-git-bot 566b08977a Merge PR #2206 into 15.0
Signed-off-by StefanRijnhart
2021-11-15 20:17:23 +00:00
Sylvain LE GAL 5b4f3cc0d0 [REF] in coverage module file, split column into 2. a column that should be filled by openupgrader, and a column that is automatically filled when importing apriori and making analysis 2021-11-15 14:05:35 +01:00
Sylvain LE GAL 0d77336caf [IMP] upgrade_analysis : prefill status with trivial information 2021-11-15 01:08:36 +01:00
Sylvain LE GAL ef0c459b37 [IMP] upgrade_coverage : generate coverage module file 2021-11-15 01:08:36 +01:00
OCA-git-bot d4e9f7cf34 [ADD] setup.py 2021-11-10 20:13:41 +00:00
OCA-git-bot ce48ef8e05 [UPD] README.rst 2021-11-10 20:13:40 +00:00
OCA-git-bot ae133fbb4e [UPD] addons table in README.md 2021-11-10 20:13:39 +00:00