Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][MIG] module_auto_update: Migration to 18.0 #3119

Open
wants to merge 25 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4ecd42a
README.rst
OCA-git-bot Jul 15, 2022
32be0a8
Added translation using Weblate (Spanish (Argentina))
ibuioli Sep 4, 2022
61e4486
Translated using Weblate (Spanish (Argentina))
ibuioli Sep 4, 2022
084d94f
dotfiles
StefanRijnhart Jan 15, 2023
e4288e5
module_auto_update 15.0.1.0.1
OCA-git-bot Jan 15, 2023
458d4ed
module_auto_update: Migration to 16.0
fkantelberg Feb 7, 2023
c88e79a
Update module_auto_update.pot
Apr 13, 2023
e63420c
README.rst
OCA-git-bot Apr 13, 2023
d66d47b
Update translation files
weblate Apr 13, 2023
e2be565
Update module_auto_update.pot
Jun 7, 2023
3b88968
Update translation files
weblate Jun 7, 2023
d1e6e8d
Translated using Weblate (Spanish (Argentina))
ibuioli Jun 9, 2023
48cbb7e
Translated using Weblate (Spanish)
Ivorra78 Aug 27, 2023
33ca3a3
README.rst
OCA-git-bot Sep 3, 2023
f2e5b49
Translated using Weblate (Italian)
mymage Sep 21, 2023
4408dff
[IMP] module_auto_update: pre-commit auto fixes
fkantelberg Nov 24, 2023
9d3605d
[MIG] module_auto_update: Migration to 17.0
fkantelberg Nov 24, 2023
777acde
[UPD] enable test that got disabled
thomaspaulb Feb 14, 2024
b60c15d
[UPD] Update module_auto_update.pot
May 3, 2024
469c4ee
[BOT] post-merge updates
OCA-git-bot May 3, 2024
dd921d9
Update translation files
weblate May 3, 2024
2da5d68
Translated using Weblate (Italian)
mymage May 3, 2024
95be1c1
Translated using Weblate (Chinese (Simplified) (zh_CN))
xtanuiha Jun 16, 2024
51a8cba
[IMP] module_auto_update: pre-commit auto fixes
pfranck Nov 13, 2024
aa52964
[MIG] module_auto_update: Migration to 18.0
pfranck Nov 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions module_auto_update/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
==================
Module Auto Update
==================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3544468e931dc11637cfb88c85e1486accc4d9252d879ce9e8a0ba4a7ccedfbd
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
:target: https://odoo-community.org/page/development-status
:alt: Production/Stable
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
:target: https://github.com/OCA/server-tools/tree/18.0/module_auto_update
:alt: OCA/server-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-tools-18-0/server-tools-18-0-module_auto_update
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

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.

**Table of contents**

.. contents::
:local:

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.

To invoke the upgrade mechanism, navigate to *Apps* menu and use the
*Auto-Upgrade Modules* button, available only in developer mode.
Restarting the Odoo instance is highly recommended to minify risk of any
possible issues.

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

.. code:: python

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

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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20module_auto_update%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* LasLabs
* Juan José Scarafía
* Tecnativa
* ACSONE SA/NV

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

- Brent Hughes <[email protected]>
- Juan José Scarafía <[email protected]>
- Jairo Llopis <[email protected]>
- Stéphane Bidoul <[email protected]> (https://acsone.eu)
- Eric Antones <[email protected]>
- Manuel Engel <[email protected]>

Maintainers
-----------

This module is maintained by the OCA.

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

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.

This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/18.0/module_auto_update>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions module_auto_update/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

from . import models
from .hooks import uninstall_hook
22 changes: 22 additions & 0 deletions module_auto_update/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2017 LasLabs Inc.
# Copyright 2018 Brainbean Apps (https://brainbeanapps.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

{
"name": "Module Auto Update",
"summary": "Automatically update Odoo modules",
"version": "18.0.1.0.0",
"category": "Extra Tools",
"website": "https://github.com/OCA/server-tools",
"author": "LasLabs, "
"Juan José Scarafía, "
"Tecnativa, "
"ACSONE SA/NV, "
"Odoo Community Association (OCA)",
"license": "LGPL-3",
"installable": True,
"uninstall_hook": "uninstall_hook",
"depends": ["base"],
"data": ["views/ir_module_module.xml"],
"development_status": "Production/Stable",
}
44 changes: 44 additions & 0 deletions module_auto_update/addon_hash.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2018 ACSONE SA/NV.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

import hashlib
import os
from fnmatch import fnmatch


def _fnmatch(filename, patterns):
for pattern in patterns:
if fnmatch(filename, pattern):
return True
return False


def _walk(top, exclude_patterns, keep_langs):
keep_langs = {language.split("_")[0] for language in keep_langs}
for dirpath, dirnames, filenames in os.walk(top):
dirnames.sort()
reldir = os.path.relpath(dirpath, top)
if reldir == ".":
reldir = ""
for filename in sorted(filenames):
filepath = os.path.join(reldir, filename)
if _fnmatch(filepath, exclude_patterns):
continue
if keep_langs and reldir in {"i18n", "i18n_extra"}:
basename, ext = os.path.splitext(filename)
if ext == ".po":
if basename.split("_")[0] not in keep_langs:
continue
yield filepath


def addon_hash(top, exclude_patterns, keep_langs):
"""Compute a sha1 digest of file contents."""
m = hashlib.sha1()
for filepath in _walk(top, exclude_patterns, keep_langs):
# hash filename so empty files influence the hash
m.update(filepath.encode("utf-8"))
# hash file content
with open(os.path.join(top, filepath), "rb") as f:
m.update(f.read())
return m.hexdigest()
11 changes: 11 additions & 0 deletions module_auto_update/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2017 LasLabs Inc.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

from odoo import SUPERUSER_ID, api

from .models.module import PARAM_INSTALLED_CHECKSUMS


def uninstall_hook(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
env["ir.config_parameter"].set_param(PARAM_INSTALLED_CHECKSUMS, False)
46 changes: 46 additions & 0 deletions module_auto_update/i18n/ca.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * module_auto_update
#
# Translators:
# OCA Transbot <[email protected]>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-07-21 02:43+0000\n"
"PO-Revision-Date: 2017-07-21 02:43+0000\n"
"Last-Translator: OCA Transbot <[email protected]>, 2017\n"
"Language-Team: Catalan (https://www.transifex.com/oca/teams/23907/ca/)\n"
"Language: ca\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: module_auto_update
#: model:ir.actions.server,name:module_auto_update.ir_module_module_upgrade_changed_checksum
#: model:ir.ui.menu,name:module_auto_update.menu_ir_module_module_upgrade_changed_checksum
msgid "Auto-Upgrade Modules"
msgstr ""

#. module: module_auto_update
#. odoo-python
#: code:addons/module_auto_update/models/module.py:0
#, python-format
msgid "Checksum upgrade complete."
msgstr ""

#. module: module_auto_update
#: model:ir.model,name:module_auto_update.model_ir_module_module
msgid "Module"
msgstr "Mòdul"

#. module: module_auto_update
#. odoo-python
#: code:addons/module_auto_update/models/module.py:0
#, python-format
msgid ""
"No checksum change detected in installed modules and all modules installed, "
"nothing to do."
msgstr ""
71 changes: 71 additions & 0 deletions module_auto_update/i18n/cs_CZ.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * module_auto_update
#
# Translators:
# Lukáš Spurný <[email protected]>, 2018
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-03-03 10:08+0000\n"
"PO-Revision-Date: 2018-03-03 10:08+0000\n"
"Last-Translator: Lukáš Spurný <[email protected]>, 2018\n"
"Language-Team: Czech (Czech Republic) (https://www.transifex.com/oca/"
"teams/23907/cs_CZ/)\n"
"Language: cs_CZ\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"

#. module: module_auto_update
#: model:ir.actions.server,name:module_auto_update.ir_module_module_upgrade_changed_checksum
#: model:ir.ui.menu,name:module_auto_update.menu_ir_module_module_upgrade_changed_checksum
msgid "Auto-Upgrade Modules"
msgstr ""

#. module: module_auto_update
#. odoo-python
#: code:addons/module_auto_update/models/module.py:0
#, python-format
msgid "Checksum upgrade complete."
msgstr ""

#. module: module_auto_update
#: model:ir.model,name:module_auto_update.model_ir_module_module
msgid "Module"
msgstr "Modul"

#. module: module_auto_update
#. odoo-python
#: code:addons/module_auto_update/models/module.py:0
#, python-format
msgid ""
"No checksum change detected in installed modules and all modules installed, "
"nothing to do."
msgstr ""

#~ msgid "Checksum Dir"
#~ msgstr "Kontrolní součet Dir"

#~ msgid "Checksum Installed"
#~ msgstr "Kontrolní součet je nainstalován"

#~ msgid "Module Upgrade"
#~ msgstr "Aktualizace modulů"

#~ msgid "Perform Module Upgrades"
#~ msgstr "Provést aktualizaci modulů"

#~ msgid "Modules"
#~ msgstr "Moduly"

#~ msgid "Open Updates and Update Apps List Server Action"
#~ msgstr "Otevřít aktualizaci a aktualizovat seznam serverových akcí"

#~ msgid "Scheduled Upgrades"
#~ msgstr "Plánované aktualizace"

#~ msgid "Updates"
#~ msgstr "Aktualizace"
53 changes: 53 additions & 0 deletions module_auto_update/i18n/de.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * module_auto_update
#
# Translators:
# Niki Waibel <[email protected]>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-07-21 02:43+0000\n"
"PO-Revision-Date: 2017-07-21 02:43+0000\n"
"Last-Translator: Niki Waibel <[email protected]>, 2017\n"
"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: module_auto_update
#: model:ir.actions.server,name:module_auto_update.ir_module_module_upgrade_changed_checksum
#: model:ir.ui.menu,name:module_auto_update.menu_ir_module_module_upgrade_changed_checksum
msgid "Auto-Upgrade Modules"
msgstr ""

#. module: module_auto_update
#. odoo-python
#: code:addons/module_auto_update/models/module.py:0
#, python-format
msgid "Checksum upgrade complete."
msgstr ""

#. module: module_auto_update
#: model:ir.model,name:module_auto_update.model_ir_module_module
msgid "Module"
msgstr "Modul"

#. module: module_auto_update
#. odoo-python
#: code:addons/module_auto_update/models/module.py:0
#, python-format
msgid ""
"No checksum change detected in installed modules and all modules installed, "
"nothing to do."
msgstr ""

#~ msgid "Module Upgrade"
#~ msgstr "Modul aktualisieren"

#, fuzzy
#~ msgid "Perform Module Upgrades"
#~ msgstr "Modul aktualisieren"
Loading
Loading