Skip to content

Commit

Permalink
Merge PR #2543 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by hbrunn
  • Loading branch information
OCA-git-bot committed Apr 13, 2023
2 parents 2913604 + f555e90 commit c8a05e8
Show file tree
Hide file tree
Showing 48 changed files with 2,067 additions and 0 deletions.
123 changes: 123 additions & 0 deletions module_auto_update/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
==================
Module Auto Update
==================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/15.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-15-0/server-tools-15-0-module_auto_update
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/149/15.0
:alt: Try me on Runbot

|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-block:: 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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20module_auto_update%0Aversion:%2015.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 <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)
* Eric Antones <eantones@nuobit.com>
* Manuel Engel <manuel.engel@initos.com>

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/15.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": "16.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)
50 changes: 50 additions & 0 deletions module_auto_update/i18n/ca.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * module_auto_update
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 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 <transbot@odoo-community.org>, 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
#: model:ir.model.fields,field_description:module_auto_update.field_ir_module_module__display_name
msgid "Display Name"
msgstr ""

#. module: module_auto_update
#: model:ir.model.fields,field_description:module_auto_update.field_ir_module_module__id
msgid "ID"
msgstr ""

#. module: module_auto_update
#: model:ir.model.fields,field_description:module_auto_update.field_ir_module_module____last_update
msgid "Last Modified on"
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
#: model:ir.model.fields,field_description:module_auto_update.field_ir_module_module__smart_search
msgid "Smart Search"
msgstr ""
75 changes: 75 additions & 0 deletions module_auto_update/i18n/cs_CZ.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * module_auto_update
#
# Translators:
# Lukáš Spurný <lukasspurny8@gmail.com>, 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ý <lukasspurny8@gmail.com>, 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
#: model:ir.model.fields,field_description:module_auto_update.field_ir_module_module__display_name
msgid "Display Name"
msgstr ""

#. module: module_auto_update
#: model:ir.model.fields,field_description:module_auto_update.field_ir_module_module__id
msgid "ID"
msgstr ""

#. module: module_auto_update
#: model:ir.model.fields,field_description:module_auto_update.field_ir_module_module____last_update
msgid "Last Modified on"
msgstr ""

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

#. module: module_auto_update
#: model:ir.model.fields,field_description:module_auto_update.field_ir_module_module__smart_search
msgid "Smart Search"
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"
57 changes: 57 additions & 0 deletions module_auto_update/i18n/de.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * module_auto_update
#
# Translators:
# Niki Waibel <niki.waibel@gmail.com>, 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 <niki.waibel@gmail.com>, 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
#: model:ir.model.fields,field_description:module_auto_update.field_ir_module_module__display_name
msgid "Display Name"
msgstr ""

#. module: module_auto_update
#: model:ir.model.fields,field_description:module_auto_update.field_ir_module_module__id
msgid "ID"
msgstr ""

#. module: module_auto_update
#: model:ir.model.fields,field_description:module_auto_update.field_ir_module_module____last_update
msgid "Last Modified on"
msgstr ""

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

#. module: module_auto_update
#: model:ir.model.fields,field_description:module_auto_update.field_ir_module_module__smart_search
msgid "Smart Search"
msgstr ""

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

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

0 comments on commit c8a05e8

Please sign in to comment.