Browse Source
Merge pull request #1118 from Tecnativa/11.0-module_auto_update
Merge pull request #1118 from Tecnativa/11.0-module_auto_update
[MIG] module_auto_update: Migrate to v11pull/1074/merge
Pedro M. Baeza
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 1211 additions and 0 deletions
-
77module_auto_update/README.rst
-
5module_auto_update/__init__.py
-
30module_auto_update/__manifest__.py
-
20module_auto_update/data/cron_data.xml
-
13module_auto_update/hooks.py
-
59module_auto_update/i18n/ca.po
-
59module_auto_update/i18n/de.po
-
59module_auto_update/i18n/es.po
-
59module_auto_update/i18n/es_MX.po
-
59module_auto_update/i18n/hr.po
-
59module_auto_update/i18n/it.po
-
59module_auto_update/i18n/nl_NL.po
-
59module_auto_update/i18n/pt_BR.po
-
59module_auto_update/i18n/sl.po
-
59module_auto_update/i18n/tr.po
-
3module_auto_update/models/__init__.py
-
69module_auto_update/models/module.py
-
4module_auto_update/tests/__init__.py
-
255module_auto_update/tests/test_module.py
-
43module_auto_update/tests/test_module_upgrade.py
-
49module_auto_update/views/module_views.xml
-
3module_auto_update/wizards/__init__.py
-
49module_auto_update/wizards/module_upgrade.py
-
1requirements.txt
@ -0,0 +1,77 @@ |
|||
.. 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 module will automatically check for and apply module upgrades on a schedule. |
|||
|
|||
Upgrade checking is accomplished by comparing the SHA1 checksums of currently-installed modules to the checksums of corresponding modules in the addons directories. |
|||
|
|||
Installation |
|||
============ |
|||
|
|||
Prior to installing this module, you need to: |
|||
|
|||
#. Install checksumdir with ``pip install checksumdir`` |
|||
#. Ensure all installed modules are up-to-date. When installed, this module will assume the versions found in the addons directories are currently installed. |
|||
|
|||
Configuration |
|||
============= |
|||
|
|||
The default time for checking and applying upgrades is 3:00 AM (UTC). To change this schedule, modify the "Perform Module Upgrades" scheduled action. |
|||
|
|||
This module will ignore ``.pyc`` and ``.pyo`` file extensions by default. To modify this, create a ``module_auto_update.checksum_excluded_extensions`` system parameter with the desired extensions listed as comma-separated values. |
|||
|
|||
Usage |
|||
===== |
|||
|
|||
Modules scheduled for upgrade can be viewed by clicking the "Updates" menu item in the Apps sidebar. |
|||
|
|||
To perform upgrades manually, click the "Apply Scheduled Upgrades" menu item in the Apps sidebar. |
|||
|
|||
.. 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 |
|||
|
|||
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> |
|||
|
|||
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. |
@ -0,0 +1,5 @@ |
|||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). |
|||
|
|||
from . import models |
|||
from . import wizards |
|||
from .hooks import post_init_hook |
@ -0,0 +1,30 @@ |
|||
# 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': '11.0.1.0.0', |
|||
'category': 'Extra Tools', |
|||
'website': 'https://odoo-community.org/', |
|||
'author': 'LasLabs, ' |
|||
'Juan José Scarafía, ' |
|||
'Tecnativa, ' |
|||
'Odoo Community Association (OCA)', |
|||
'license': 'LGPL-3', |
|||
'application': False, |
|||
'installable': True, |
|||
'post_init_hook': 'post_init_hook', |
|||
'external_dependencies': { |
|||
'python': [ |
|||
'checksumdir', |
|||
], |
|||
}, |
|||
'depends': [ |
|||
'base', |
|||
], |
|||
'data': [ |
|||
'views/module_views.xml', |
|||
'data/cron_data.xml', |
|||
], |
|||
} |
@ -0,0 +1,20 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- Copyright 2017 LasLabs - Dave Lasley |
|||
Copyright 2017 Tecnativa - Jairo Llopis |
|||
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). --> |
|||
|
|||
<odoo noupdate="1"> |
|||
<record model="ir.cron" id="module_check_upgrades_cron"> |
|||
<field name="name">Perform Module Upgrades</field> |
|||
<field name="active" eval="True"/> |
|||
<field name="user_id" ref="base.user_root"/> |
|||
<field name="interval_number">1</field> |
|||
<field name="interval_type">days</field> |
|||
<field name="numbercall">-1</field> |
|||
<field name="nextcall" eval="(DateTime.now() + timedelta(days= +1)).strftime('%Y-%m-%d 3:00:00')"/> |
|||
<field name="model_id" ref="base.model_base_module_upgrade"/> |
|||
<field name="state">code</field> |
|||
<field name="code">model.upgrade_module()</field> |
|||
|
|||
</record> |
|||
</odoo> |
@ -0,0 +1,13 @@ |
|||
# Copyright 2017 LasLabs Inc. |
|||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). |
|||
|
|||
from odoo import SUPERUSER_ID, api |
|||
|
|||
|
|||
def post_init_hook(cr, registry): |
|||
env = api.Environment(cr, SUPERUSER_ID, {}) |
|||
installed_modules = env['ir.module.module'].search([ |
|||
('state', '=', 'installed'), |
|||
]) |
|||
for r in installed_modules: |
|||
r.checksum_installed = r.checksum_dir |
@ -0,0 +1,59 @@ |
|||
# 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" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Language: ca\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.ui.menu,name:module_auto_update.menu_default_modules |
|||
msgid "Modules" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.actions.server,name:module_auto_update.module_action_open_updates |
|||
msgid "Open Updates and Update Apps List Server Action" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.ui.view,arch_db:module_auto_update.module_view_search |
|||
msgid "Scheduled Upgrades" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.ui.menu,name:module_auto_update.module_menu_updates |
|||
msgid "Updates" |
|||
msgstr "" |
@ -0,0 +1,59 @@ |
|||
# 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" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Language: de\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 "Modul" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.model,name:module_auto_update.model_base_module_upgrade |
|||
msgid "Module Upgrade" |
|||
msgstr "Modul aktualisieren" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.ui.menu,name:module_auto_update.menu_default_modules |
|||
msgid "Modules" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.actions.server,name:module_auto_update.module_action_open_updates |
|||
msgid "Open Updates and Update Apps List Server Action" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.ui.view,arch_db:module_auto_update.module_view_search |
|||
msgid "Scheduled Upgrades" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.ui.menu,name:module_auto_update.module_menu_updates |
|||
msgid "Updates" |
|||
msgstr "" |
@ -0,0 +1,59 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * module_auto_update |
|||
# |
|||
# Translators: |
|||
# Pedro M. Baeza <pedro.baeza@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: Pedro M. Baeza <pedro.baeza@gmail.com>, 2017\n" |
|||
"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Language: es\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ódulo" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.model,name:module_auto_update.model_base_module_upgrade |
|||
msgid "Module Upgrade" |
|||
msgstr "Actualización de módulo" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.ui.menu,name:module_auto_update.menu_default_modules |
|||
msgid "Modules" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.actions.server,name:module_auto_update.module_action_open_updates |
|||
msgid "Open Updates and Update Apps List Server Action" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.ui.view,arch_db:module_auto_update.module_view_search |
|||
msgid "Scheduled Upgrades" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.ui.menu,name:module_auto_update.module_menu_updates |
|||
msgid "Updates" |
|||
msgstr "" |
@ -0,0 +1,59 @@ |
|||
# 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: Spanish (Mexico) (https://www.transifex.com/oca/teams/23907/es_MX/)\n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Language: es_MX\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ódulo" |
|||
|
|||
#. 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.ui.menu,name:module_auto_update.menu_default_modules |
|||
msgid "Modules" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.actions.server,name:module_auto_update.module_action_open_updates |
|||
msgid "Open Updates and Update Apps List Server Action" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.ui.view,arch_db:module_auto_update.module_view_search |
|||
msgid "Scheduled Upgrades" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.ui.menu,name:module_auto_update.module_menu_updates |
|||
msgid "Updates" |
|||
msgstr "" |
@ -0,0 +1,59 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * module_auto_update |
|||
# |
|||
# Translators: |
|||
# Bole <bole@dajmi5.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: Bole <bole@dajmi5.com>, 2017\n" |
|||
"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Language: hr\n" |
|||
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 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 "" |
|||
|
|||
#. 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 "Modul" |
|||
|
|||
#. 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.ui.menu,name:module_auto_update.menu_default_modules |
|||
msgid "Modules" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.actions.server,name:module_auto_update.module_action_open_updates |
|||
msgid "Open Updates and Update Apps List Server Action" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.ui.view,arch_db:module_auto_update.module_view_search |
|||
msgid "Scheduled Upgrades" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.ui.menu,name:module_auto_update.module_menu_updates |
|||
msgid "Updates" |
|||
msgstr "" |
@ -0,0 +1,59 @@ |
|||
# 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: Italian (https://www.transifex.com/oca/teams/23907/it/)\n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Language: it\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 "Modulo" |
|||
|
|||
#. 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.ui.menu,name:module_auto_update.menu_default_modules |
|||
msgid "Modules" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.actions.server,name:module_auto_update.module_action_open_updates |
|||
msgid "Open Updates and Update Apps List Server Action" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.ui.view,arch_db:module_auto_update.module_view_search |
|||
msgid "Scheduled Upgrades" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.ui.menu,name:module_auto_update.module_menu_updates |
|||
msgid "Updates" |
|||
msgstr "" |
@ -0,0 +1,59 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * module_auto_update |
|||
# |
|||
# Translators: |
|||
# Peter Hageman <hageman.p@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: Peter Hageman <hageman.p@gmail.com>, 2017\n" |
|||
"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/teams/23907/nl_NL/)\n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Language: nl_NL\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 "Module" |
|||
|
|||
#. 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.ui.menu,name:module_auto_update.menu_default_modules |
|||
msgid "Modules" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.actions.server,name:module_auto_update.module_action_open_updates |
|||
msgid "Open Updates and Update Apps List Server Action" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.ui.view,arch_db:module_auto_update.module_view_search |
|||
msgid "Scheduled Upgrades" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.ui.menu,name:module_auto_update.module_menu_updates |
|||
msgid "Updates" |
|||
msgstr "" |
@ -0,0 +1,59 @@ |
|||
# 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: Portuguese (Brazil) (https://www.transifex.com/oca/teams/23907/pt_BR/)\n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Language: pt_BR\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ódulo" |
|||
|
|||
#. 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.ui.menu,name:module_auto_update.menu_default_modules |
|||
msgid "Modules" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.actions.server,name:module_auto_update.module_action_open_updates |
|||
msgid "Open Updates and Update Apps List Server Action" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.ui.view,arch_db:module_auto_update.module_view_search |
|||
msgid "Scheduled Upgrades" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.ui.menu,name:module_auto_update.module_menu_updates |
|||
msgid "Updates" |
|||
msgstr "" |
@ -0,0 +1,59 @@ |
|||
# 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: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Language: sl\n" |
|||
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\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 "Modul" |
|||
|
|||
#. 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.ui.menu,name:module_auto_update.menu_default_modules |
|||
msgid "Modules" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.actions.server,name:module_auto_update.module_action_open_updates |
|||
msgid "Open Updates and Update Apps List Server Action" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.ui.view,arch_db:module_auto_update.module_view_search |
|||
msgid "Scheduled Upgrades" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.ui.menu,name:module_auto_update.module_menu_updates |
|||
msgid "Updates" |
|||
msgstr "" |
@ -0,0 +1,59 @@ |
|||
# 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: Turkish (https://www.transifex.com/oca/teams/23907/tr/)\n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Language: tr\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 "Modül" |
|||
|
|||
#. 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.ui.menu,name:module_auto_update.menu_default_modules |
|||
msgid "Modules" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.actions.server,name:module_auto_update.module_action_open_updates |
|||
msgid "Open Updates and Update Apps List Server Action" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.ui.view,arch_db:module_auto_update.module_view_search |
|||
msgid "Scheduled Upgrades" |
|||
msgstr "" |
|||
|
|||
#. module: module_auto_update |
|||
#: model:ir.ui.menu,name:module_auto_update.module_menu_updates |
|||
msgid "Updates" |
|||
msgstr "" |
@ -0,0 +1,3 @@ |
|||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). |
|||
|
|||
from . import module |
@ -0,0 +1,69 @@ |
|||
# Copyright 2017 LasLabs Inc. |
|||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). |
|||
|
|||
import logging |
|||
|
|||
from odoo import api, fields, models |
|||
from odoo.modules.module import get_module_path |
|||
|
|||
_logger = logging.getLogger(__name__) |
|||
try: |
|||
from checksumdir import dirhash |
|||
except ImportError: |
|||
_logger.debug('Cannot `import checksumdir`.') |
|||
|
|||
|
|||
class Module(models.Model): |
|||
_inherit = 'ir.module.module' |
|||
|
|||
checksum_dir = fields.Char( |
|||
compute='_compute_checksum_dir', |
|||
) |
|||
checksum_installed = fields.Char() |
|||
|
|||
@api.depends('name') |
|||
def _compute_checksum_dir(self): |
|||
exclude = self.env["ir.config_parameter"].get_param( |
|||
"module_auto_update.checksum_excluded_extensions", |
|||
"pyc,pyo", |
|||
).split(",") |
|||
|
|||
for r in self: |
|||
try: |
|||
r.checksum_dir = dirhash( |
|||
get_module_path(r.name), |
|||
'sha1', |
|||
excluded_extensions=exclude, |
|||
) |
|||
except TypeError: |
|||
_logger.debug( |
|||
"Cannot compute dir hash for %s, module not found", |
|||
r.display_name) |
|||
|
|||
@api.multi |
|||
def _store_checksum_installed(self, vals): |
|||
"""Store the right installed checksum, if addon is installed.""" |
|||
if 'checksum_installed' not in vals: |
|||
try: |
|||
version = vals["latest_version"] |
|||
except KeyError: |
|||
return # Not [un]installing/updating any addon |
|||
if version is False: |
|||
# Uninstalling |
|||
self.write({'checksum_installed': False}) |
|||
else: |
|||
# Installing or updating |
|||
for one in self: |
|||
one.checksum_installed = one.checksum_dir |
|||
|
|||
@api.model |
|||
def create(self, vals): |
|||
res = super(Module, self).create(vals) |
|||
res._store_checksum_installed(vals) |
|||
return res |
|||
|
|||
@api.multi |
|||
def write(self, vals): |
|||
res = super(Module, self).write(vals) |
|||
self._store_checksum_installed(vals) |
|||
return res |
@ -0,0 +1,4 @@ |
|||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). |
|||
|
|||
from . import test_module |
|||
from . import test_module_upgrade |
@ -0,0 +1,255 @@ |
|||
# Copyright 2017 LasLabs Inc. |
|||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). |
|||
|
|||
import logging |
|||
import os |
|||
import tempfile |
|||
|
|||
import mock |
|||
|
|||
from odoo.modules import get_module_path |
|||
from odoo.tests.common import TransactionCase |
|||
from odoo.tools import mute_logger |
|||
|
|||
from .. import post_init_hook |
|||
|
|||
_logger = logging.getLogger(__name__) |
|||
try: |
|||
from checksumdir import dirhash |
|||
except ImportError: |
|||
_logger.debug('Cannot `import checksumdir`.') |
|||
|
|||
model = 'odoo.addons.module_auto_update.models.module' |
|||
|
|||
|
|||
class EndTestException(Exception): |
|||
pass |
|||
|
|||
|
|||
class TestModule(TransactionCase): |
|||
|
|||
def setUp(self): |
|||
super(TestModule, self).setUp() |
|||
module_name = 'module_auto_update' |
|||
self.own_module = self.env['ir.module.module'].search([ |
|||
('name', '=', module_name), |
|||
]) |
|||
self.own_dir_path = get_module_path(module_name) |
|||
self.own_checksum = dirhash( |
|||
self.own_dir_path, |
|||
'sha1', |
|||
excluded_extensions=['pyc', 'pyo'], |
|||
) |
|||
self.own_writeable = os.access(self.own_dir_path, os.W_OK) |
|||
|
|||
@mock.patch('%s.get_module_path' % model) |
|||
def create_test_module(self, vals, get_module_path_mock): |
|||
get_module_path_mock.return_value = self.own_dir_path |
|||
test_module = self.env['ir.module.module'].create(vals) |
|||
return test_module |
|||
|
|||
def test_compute_checksum_dir(self): |
|||
"""It should compute the directory's SHA-1 hash""" |
|||
self.assertEqual( |
|||
self.own_module.checksum_dir, self.own_checksum, |
|||
'Module directory checksum not computed properly', |
|||
) |
|||
|
|||
def test_compute_checksum_dir_ignore_excluded(self): |
|||
"""It should exclude .pyc/.pyo extensions from checksum |
|||
calculations""" |
|||
if not self.own_writeable: |
|||
self.skipTest("Own directory not writeable") |
|||
with tempfile.NamedTemporaryFile( |
|||
suffix='.pyc', dir=self.own_dir_path): |
|||
self.assertEqual( |
|||
self.own_module.checksum_dir, self.own_checksum, |
|||
'SHA1 checksum does not ignore excluded extensions', |
|||
) |
|||
|
|||
def test_compute_checksum_dir_recomputes_when_file_added(self): |
|||
"""It should return a different value when a non-.pyc/.pyo file is |
|||
added to the module directory""" |
|||
if not self.own_writeable: |
|||
self.skipTest("Own directory not writeable") |
|||
with tempfile.NamedTemporaryFile( |
|||
suffix='.py', dir=self.own_dir_path): |
|||
self.assertNotEqual( |
|||
self.own_module.checksum_dir, self.own_checksum, |
|||
'SHA1 checksum not recomputed', |
|||
) |
|||
|
|||
def test_store_checksum_installed_state_installed(self): |
|||
"""It should set the module's checksum_installed equal to |
|||
checksum_dir when vals contain a ``latest_version`` str.""" |
|||
self.own_module.checksum_installed = 'test' |
|||
self.own_module._store_checksum_installed({'latest_version': '1.0'}) |
|||
self.assertEqual( |
|||
self.own_module.checksum_installed, self.own_module.checksum_dir, |
|||
) |
|||
|
|||
def test_store_checksum_installed_state_uninstalled(self): |
|||
"""It should clear the module's checksum_installed when vals |
|||
contain ``"latest_version": False``""" |
|||
self.own_module.checksum_installed = 'test' |
|||
self.own_module._store_checksum_installed({'latest_version': False}) |
|||
self.assertIs(self.own_module.checksum_installed, False) |
|||
|
|||
def test_store_checksum_installed_vals_contain_checksum_installed(self): |
|||
"""It should not set checksum_installed to False or checksum_dir when |
|||
a checksum_installed is included in vals""" |
|||
self.own_module.checksum_installed = 'test' |
|||
self.own_module._store_checksum_installed({ |
|||
'state': 'installed', |
|||
'checksum_installed': 'test', |
|||
}) |
|||
self.assertEqual( |
|||
self.own_module.checksum_installed, 'test', |
|||
'Providing checksum_installed in vals did not prevent overwrite', |
|||
) |
|||
|
|||
def test_store_checksum_installed_with_retain_context(self): |
|||
"""It should not set checksum_installed to False or checksum_dir when |
|||
self has context retain_checksum_installed=True""" |
|||
self.own_module.checksum_installed = 'test' |
|||
self.own_module.with_context( |
|||
retain_checksum_installed=True, |
|||
)._store_checksum_installed({'state': 'installed'}) |
|||
self.assertEqual( |
|||
self.own_module.checksum_installed, 'test', |
|||
'Providing retain_checksum_installed context did not prevent ' |
|||
'overwrite', |
|||
) |
|||
|
|||
@mock.patch('%s.get_module_path' % model) |
|||
def test_button_uninstall_no_recompute(self, module_path_mock): |
|||
"""It should not attempt update on `button_uninstall`.""" |
|||
module_path_mock.return_value = self.own_dir_path |
|||
vals = { |
|||
'name': 'module_auto_update_test_module', |
|||
'state': 'installed', |
|||
} |
|||
test_module = self.create_test_module(vals) |
|||
test_module.checksum_installed = 'test' |
|||
uninstall_module = self.env['ir.module.module'].search([ |
|||
('name', '=', 'web'), |
|||
]) |
|||
uninstall_module.button_uninstall() |
|||
self.assertNotEqual( |
|||
test_module.state, 'to upgrade', |
|||
'Auto update logic was triggered during uninstall.', |
|||
) |
|||
|
|||
def test_button_immediate_uninstall_no_recompute(self): |
|||
"""It should not attempt update on `button_immediate_uninstall`.""" |
|||
|
|||
uninstall_module = self.env['ir.module.module'].search([ |
|||
('name', '=', 'web'), |
|||
]) |
|||
|
|||
try: |
|||
mk = mock.MagicMock() |
|||
uninstall_module._patch_method('button_uninstall', mk) |
|||
mk.side_effect = EndTestException |
|||
with self.assertRaises(EndTestException): |
|||
uninstall_module.button_immediate_uninstall() |
|||
finally: |
|||
uninstall_module._revert_method('button_uninstall') |
|||
|
|||
def test_button_uninstall_cancel(self): |
|||
"""It should preserve checksum_installed when cancelling uninstall""" |
|||
self.own_module.write({'state': 'to remove'}) |
|||
self.own_module.checksum_installed = 'test' |
|||
self.own_module.button_uninstall_cancel() |
|||
self.assertEqual( |
|||
self.own_module.checksum_installed, 'test', |
|||
'Uninstall cancellation does not preserve checksum_installed', |
|||
) |
|||
|
|||
def test_button_upgrade_cancel(self): |
|||
"""It should preserve checksum_installed when cancelling upgrades""" |
|||
self.own_module.write({'state': 'to upgrade'}) |
|||
self.own_module.checksum_installed = 'test' |
|||
self.own_module.button_upgrade_cancel() |
|||
self.assertEqual( |
|||
self.own_module.checksum_installed, 'test', |
|||
'Upgrade cancellation does not preserve checksum_installed', |
|||
) |
|||
|
|||
def test_create(self): |
|||
"""It should call _store_checksum_installed method""" |
|||
_store_checksum_installed_mock = mock.MagicMock() |
|||
self.env['ir.module.module']._patch_method( |
|||
'_store_checksum_installed', |
|||
_store_checksum_installed_mock, |
|||
) |
|||
vals = { |
|||
'name': 'module_auto_update_test_module', |
|||
'state': 'installed', |
|||
} |
|||
self.create_test_module(vals) |
|||
_store_checksum_installed_mock.assert_called_once_with(vals) |
|||
self.env['ir.module.module']._revert_method( |
|||
'_store_checksum_installed', |
|||
) |
|||
|
|||
@mute_logger("openerp.modules.module") |
|||
@mock.patch('%s.get_module_path' % model) |
|||
def test_get_module_list(self, module_path_mock): |
|||
"""It should change the state of modules with different |
|||
checksum_dir and checksum_installed to 'to upgrade'""" |
|||
module_path_mock.return_value = self.own_dir_path |
|||
vals = { |
|||
'name': 'module_auto_update_test_module', |
|||
'state': 'installed', |
|||
} |
|||
test_module = self.create_test_module(vals) |
|||
test_module.checksum_installed = 'test' |
|||
self.env['base.module.upgrade'].get_module_list() |
|||
self.assertEqual( |
|||
test_module.state, 'to upgrade', |
|||
'List update does not mark upgradeable modules "to upgrade"', |
|||
) |
|||
|
|||
@mock.patch('%s.get_module_path' % model) |
|||
def test_get_module_list_only_changes_installed(self, module_path_mock): |
|||
"""It should not change the state of a module with a former state |
|||
other than 'installed' to 'to upgrade'""" |
|||
module_path_mock.return_value = self.own_dir_path |
|||
vals = { |
|||
'name': 'module_auto_update_test_module', |
|||
'state': 'uninstalled', |
|||
} |
|||
test_module = self.create_test_module(vals) |
|||
self.env['base.module.upgrade'].get_module_list() |
|||
self.assertNotEqual( |
|||
test_module.state, 'to upgrade', |
|||
'List update changed state of an uninstalled module', |
|||
) |
|||
|
|||
def test_write(self): |
|||
"""It should call _store_checksum_installed method""" |
|||
_store_checksum_installed_mock = mock.MagicMock() |
|||
self.env['ir.module.module']._patch_method( |
|||
'_store_checksum_installed', |
|||
_store_checksum_installed_mock, |
|||
) |
|||
vals = {'state': 'installed'} |
|||
self.own_module.write(vals) |
|||
_store_checksum_installed_mock.assert_called_once_with(vals) |
|||
self.env['ir.module.module']._revert_method( |
|||
'_store_checksum_installed', |
|||
) |
|||
|
|||
def test_post_init_hook(self): |
|||
"""It should set checksum_installed equal to checksum_dir for all |
|||
installed modules""" |
|||
installed_modules = self.env['ir.module.module'].search([ |
|||
('state', '=', 'installed'), |
|||
]) |
|||
post_init_hook(self.env.cr, None) |
|||
self.assertListEqual( |
|||
installed_modules.mapped('checksum_dir'), |
|||
installed_modules.mapped('checksum_installed'), |
|||
'Installed modules did not have checksum_installed stored', |
|||
) |
@ -0,0 +1,43 @@ |
|||
# Copyright 2017 LasLabs Inc. |
|||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). |
|||
|
|||
import mock |
|||
|
|||
from odoo.modules import get_module_path |
|||
from odoo.modules.registry import Registry |
|||
from odoo.tests.common import TransactionCase |
|||
|
|||
|
|||
class TestModuleUpgrade(TransactionCase): |
|||
|
|||
def setUp(self): |
|||
super(TestModuleUpgrade, self).setUp() |
|||
module_name = 'module_auto_update' |
|||
self.own_module = self.env['ir.module.module'].search([ |
|||
('name', '=', module_name), |
|||
]) |
|||
self.own_dir_path = get_module_path(module_name) |
|||
|
|||
def test_upgrade_module_cancel(self): |
|||
"""It should preserve checksum_installed when cancelling upgrades""" |
|||
self.own_module.write({'state': 'to upgrade'}) |
|||
self.own_module.checksum_installed = 'test' |
|||
self.env['base.module.upgrade'].upgrade_module_cancel() |
|||
self.assertEqual( |
|||
self.own_module.checksum_installed, 'test', |
|||
'Upgrade cancellation does not preserve checksum_installed', |
|||
) |
|||
|
|||
@mock.patch.object(Registry, 'new') |
|||
def test_upgrade_module(self, new_mock): |
|||
"""Calls get_module_list when upgrading in api.model mode""" |
|||
get_module_list_mock = mock.MagicMock() |
|||
try: |
|||
self.env['base.module.upgrade']._patch_method( |
|||
'get_module_list', |
|||
get_module_list_mock, |
|||
) |
|||
self.env['base.module.upgrade'].upgrade_module() |
|||
get_module_list_mock.assert_called_once_with() |
|||
finally: |
|||
self.env['base.module.upgrade']._revert_method('get_module_list') |
@ -0,0 +1,49 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<!-- Module Search View --> |
|||
<record id="module_view_search" model="ir.ui.view"> |
|||
<field name="name">updates.module.search</field> |
|||
<field name="model">ir.module.module</field> |
|||
<field name="inherit_id" ref="base.view_module_filter"/> |
|||
<field name="arch" type="xml"> |
|||
<field name="category_id" position="after"> |
|||
<filter name="scheduled_upgrades" string="Scheduled Upgrades" domain="[('state', '=', 'to upgrade')]"/> |
|||
</field> |
|||
</field> |
|||
</record> |
|||
|
|||
<!--Open Updates Action (updates apps list first)--> |
|||
<record id="module_action_open_updates" model="ir.actions.server"> |
|||
<field name="name">Open Updates and Update Apps List Server Action</field> |
|||
<field name="model_id" ref="model_ir_module_module"/> |
|||
<field name="code"> |
|||
if model.update_list(): |
|||
action = { |
|||
'name': 'Updates', |
|||
'type': 'ir.actions.act_window', |
|||
'res_model': 'ir.module.module', |
|||
'view_type': 'form', |
|||
'view_mode': 'tree,form', |
|||
'target': 'main', |
|||
'context': '{"search_default_scheduled_upgrades": 1}', |
|||
} |
|||
</field> |
|||
</record> |
|||
|
|||
<!--Apps / Updates menu item--> |
|||
<menuitem |
|||
name="Updates" |
|||
action="module_action_open_updates" |
|||
id="module_menu_updates" |
|||
groups="base.group_no_one" |
|||
parent="base.menu_management" |
|||
sequence="20"/> |
|||
|
|||
<!-- Menu in Settings > Technical for standard Updates link --> |
|||
<menuitem parent="base.menu_custom" sequence="27" name="Modules" id="menu_default_modules"/> |
|||
|
|||
<!-- Moved standard Updates link --> |
|||
<record model="ir.ui.menu" id="base.menu_module_updates"> |
|||
<field name="parent_id" ref="menu_default_modules"/> |
|||
</record> |
|||
</odoo> |
@ -0,0 +1,3 @@ |
|||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). |
|||
|
|||
from . import module_upgrade |
@ -0,0 +1,49 @@ |
|||
# Copyright 2017 LasLabs Inc. |
|||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). |
|||
|
|||
from odoo import api, models |
|||
|
|||
|
|||
class ModuleUpgrade(models.TransientModel): |
|||
_inherit = 'base.module.upgrade' |
|||
|
|||
@api.model |
|||
@api.returns('ir.module.module') |
|||
def get_module_list(self): |
|||
"""Set modules to upgrade searching by their dir checksum.""" |
|||
Module = self.env["ir.module.module"] |
|||
installed_modules = Module.search([('state', '=', 'installed')]) |
|||
upgradeable_modules = installed_modules.filtered( |
|||
lambda r: r.checksum_dir != r.checksum_installed, |
|||
) |
|||
upgradeable_modules.button_upgrade() |
|||
return super(ModuleUpgrade, self).get_module_list() |
|||
|
|||
@api.multi |
|||
def upgrade_module(self): |
|||
"""Make a fully automated addon upgrade.""" |
|||
# Compute updates by checksum when called in @api.model fashion |
|||
if not self: |
|||
self.get_module_list() |
|||
Module = self.env["ir.module.module"] |
|||
# Get every addon state before updating |
|||
pre_states = {addon["name"]: addon["state"] |
|||
for addon in Module.search_read([], ["name", "state"])} |
|||
# Perform upgrades, possibly in a limited graph that excludes me |
|||
result = super(ModuleUpgrade, self).upgrade_module() |
|||
# Reload environments, anything may have changed |
|||
self.env.clear() |
|||
# Update addons checksum if state changed and I wasn't uninstalled |
|||
own = Module.search_read( |
|||
[("name", "=", "module_auto_update")], |
|||
["state"], |
|||
limit=1) |
|||
if own and own[0]["state"] != "uninstalled": |
|||
for addon in Module.search([]): |
|||
if addon.state != pre_states.get(addon.name): |
|||
# Trigger the write hook that should have been |
|||
# triggered when the module was [un]installed/updated in |
|||
# the limited module graph inside above call to super(), |
|||
# and updates its dir checksum as needed |
|||
addon.latest_version = addon.latest_version |
|||
return result |
@ -0,0 +1 @@ |
|||
checksumdir |
Write
Preview
Loading…
Cancel
Save
Reference in new issue