Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b2733bd
[ADD] module_auto_update: Create module (#882)
hughesbm Jul 20, 2017
4cf8301
OCA Transbot updated translations from Transifex
oca-transbot Jul 22, 2017
988dd83
[REF][module_auto_update] Forward port v9 improvements
yajo Aug 2, 2017
dd871c7
[FIX] module_auto_update: Don't compute upgrade on uninstall
lasley Aug 11, 2017
036bf2b
[FIX][module_auto_update] Record base addon checksum (#948)
yajo Aug 28, 2017
0173f65
[FIX][module_auto_update] Always store changes in lower graphs
yajo Aug 29, 2017
6cb5398
[MIG] module_auto_update: Migrate to v11
yajo Jan 5, 2018
2fe4edb
OCA Transbot updated translations from Transifex
oca-transbot Mar 3, 2018
fc690c4
[REF] module_auto_update: Step 1, move all deprecated stuff to deprec…
yajo Mar 16, 2018
0daf2d6
[REF] module_auto_update: Step 2, add new API
sbidoul Feb 27, 2018
006b822
[REF] module_auto_update: Step 3, backwards compatibility
yajo Mar 16, 2018
679660e
[FIX] module_auto_update: Add .pyo sample file (#1205)
yajo Mar 27, 2018
87ae683
[FIX] Forward port module_auto_update refactoring from 9.0
lmignon Mar 27, 2018
43e43e9
[FIX] module_auto_update: Rollback cursor if param exists
yajo Mar 27, 2018
759c840
[CHG] updated version number
benwillig Apr 9, 2018
c7c8a6e
module_auto_update: check a post condition
sbidoul May 17, 2018
97875e0
module_auto_update: bump version
sbidoul May 17, 2018
0792671
[FIX] module_auto_update: Ignore `__pycache__` in hash test
yajo May 22, 2018
602caa2
[10.0][FIX] module_auto_update: Don't set 'to upgrade' on void record…
rousseldenis Jun 1, 2018
238a6df
module_auto_update: sbidoul as maintainer
sbidoul Jun 2, 2018
4710f2a
module_auto_update: readme fragments
sbidoul Jun 2, 2018
d8021eb
[UPD] README.rst
sbidoul Jun 4, 2018
2d8f133
module_auto_update: 11.0.2.0.4
sbidoul Jun 4, 2018
a9882b3
[UPD] Update module_auto_update.pot
oca-travis Jun 17, 2018
fbefe9c
[UPD] README.rst
OCA-git-bot Jun 21, 2018
3e28243
[UPD] README.rst
OCA-git-bot Aug 5, 2018
003a944
Global pylint cleanup
simahawk Sep 3, 2018
3a9ece4
Align .travis.yml with template
sbidoul Oct 5, 2018
dee3f2c
Add weblate translation status in readme
sbidoul Oct 5, 2018
2c25f45
[MIG] module_auto_update from 11 to 12
sbidoul Oct 5, 2018
e278a0a
module_auto_update: cosmetics
sbidoul Oct 6, 2018
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
25 changes: 5 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,26 @@ python:

addons:
postgresql: "9.6"
postgresql: "9.3" # minimal postgresql version for the base_import_security_group module
# more info: https://github.com/OCA/maintainer-quality-tools/issues/432
apt:
packages:
- expect-dev # provides unbuffer utility
- python-lxml # because pip installation is slow

env:
global:
- VERSION="12.0" TESTS="0" LINT_CHECK="0" TRANSIFEX="0"
- TRANSIFEX_USER='transbot@odoo-community.org'
- secure: Z06mZCN+Hm3myqHSOZpOOk1pd4oq1epAWZv6m9OX2bTNHbhyOVOGK6JWWsnDm/3DUCN1ZeLtSGOl9bvQfMa8ahQHA80MkLL16YlTvQV59Lh+L2gAYmxX+ogJCJgeQSVAXlGLscgkADCu/HzDlmatrDeROMtULn5i23j2qcyUNyM=
- VERSION="12.0" TESTS="0" LINT_CHECK="0" MAKEPOT="0"

matrix:
- LINT_CHECK="1"
- TRANSIFEX="1"
- TESTS="1" ODOO_REPO="OCA/OCB" EXCLUDE="database_cleanup"
- TESTS="1" ODOO_REPO="OCA/OCB" INCLUDE="database_cleanup"
- TESTS="1" ODOO_REPO="odoo/odoo" EXCLUDE="database_cleanup"
- TESTS="1" ODOO_REPO="odoo/odoo" INCLUDE="database_cleanup"

before_install:
- "export PATH=$PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64/bin:$PATH"
- "if [ $(phantomjs --version) != '2.1.1' ]; then rm -rf $PWD/travis_phantomjs; mkdir -p $PWD/travis_phantomjs; fi"
- "if [ $(phantomjs --version) != '2.1.1' ]; then wget https://assets.membergetmember.co/software/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O $PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2; fi"
- "if [ $(phantomjs --version) != '2.1.1' ]; then tar -xvf $PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C $PWD/travis_phantomjs; fi"
- "phantomjs --version"
- TESTS="1" ODOO_REPO="OCA/OCB"
- TESTS="1" ODOO_REPO="OCA/OCB" MAKEPOT="1"

install:
- git clone https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools
- git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
- travis_install_nightly

script:
- travis_run_tests

after_success:
- travis_after_tests_success
- travis_after_tests_success
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ Do you want to contribute? Please read our [contributing guidelines](https://git

Translation Status
------------------
[![Transifex Status](https://www.transifex.com/projects/p/OCA-server-tools-12-0/chart/image_png)](https://www.transifex.com/projects/p/OCA-server-tools-12-0)
[![Translation status](https://translation.odoo-community.org/widgets/server-tools-12-0/-/multi-auto.svg)](https://translation.odoo-community.org/engage/server-tools-12-0/?utm_source=widget)
144 changes: 144 additions & 0 deletions module_auto_update/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
==================
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/11.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-11-0/server-tools-11-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/11.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.

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()

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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20module_auto_update%0Aversion:%2011.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)

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.

.. |maintainer-sbidoul| image:: https://github.com/sbidoul.png?size=40px
:target: https://github.com/sbidoul
:alt: sbidoul

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-sbidoul|

This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/11.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 (http://www.gnu.org/licenses/lgpl).

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

{
'name': 'Module Auto Update',
'summary': 'Automatically update Odoo modules',
'version': '12.0.2.0.4',
'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',
],
'development_status': 'Production/Stable',
'maintainers': ['sbidoul'],
}
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 (http://www.gnu.org/licenses/lgpl).

from fnmatch import fnmatch
import hashlib
import os


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 = {l.split('_')[0] for l 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 (http://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 <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.model.fields,field_description:module_auto_update.field_ir_module_module_checksum_dir
msgid "Checksum Dir"
msgstr ""

#. module: module_auto_update
#: model:ir.model.fields,field_description:module_auto_update.field_ir_module_module_checksum_installed
msgid "Checksum Installed"
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,name:module_auto_update.model_base_module_upgrade
msgid "Module Upgrade"
msgstr ""

#. module: module_auto_update
#: model:ir.actions.server,name:module_auto_update.module_check_upgrades_cron_ir_actions_server
#: model:ir.cron,cron_name:module_auto_update.module_check_upgrades_cron
#: model:ir.cron,name:module_auto_update.module_check_upgrades_cron
msgid "Perform Module Upgrades"
msgstr ""
59 changes: 59 additions & 0 deletions module_auto_update/i18n/cs_CZ.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# 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.model.fields,field_description:module_auto_update.field_ir_module_module_checksum_dir
msgid "Checksum Dir"
msgstr "Kontrolní součet Dir"

#. module: module_auto_update
#: model:ir.model.fields,field_description:module_auto_update.field_ir_module_module_checksum_installed
msgid "Checksum Installed"
msgstr "Kontrolní součet je nainstalován"

#. 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,name:module_auto_update.model_base_module_upgrade
msgid "Module Upgrade"
msgstr "Aktualizace modulů"

#. module: module_auto_update
#: model:ir.actions.server,name:module_auto_update.module_check_upgrades_cron_ir_actions_server
#: model:ir.cron,cron_name:module_auto_update.module_check_upgrades_cron
#: model:ir.cron,name:module_auto_update.module_check_upgrades_cron
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"
Loading