From c3ab603ee2664c9bf747f52a4536a912ad6b60b5 Mon Sep 17 00:00:00 2001 From: Alessio Renda Date: Wed, 8 Nov 2023 16:38:44 +0100 Subject: [PATCH 1/8] [IMP] module_auto_update: confirm message before updating --- module_auto_update/README.rst | 4 +- module_auto_update/__init__.py | 1 + module_auto_update/__manifest__.py | 5 +- module_auto_update/readme/CONTRIBUTORS.rst | 2 + .../security/ir.model.access.csv | 2 + .../static/description/index.html | 4 +- module_auto_update/views/ir_module_module.xml | 24 -------- module_auto_update/wizard/__init__.py | 1 + .../wizard/module_auto_update.py | 26 +++++++++ .../wizard/module_auto_update_views.xml | 56 +++++++++++++++++++ 10 files changed, 98 insertions(+), 27 deletions(-) create mode 100644 module_auto_update/security/ir.model.access.csv delete mode 100644 module_auto_update/views/ir_module_module.xml create mode 100644 module_auto_update/wizard/__init__.py create mode 100644 module_auto_update/wizard/module_auto_update.py create mode 100644 module_auto_update/wizard/module_auto_update_views.xml diff --git a/module_auto_update/README.rst b/module_auto_update/README.rst index afd7a302e03..f56ad9fc9b4 100644 --- a/module_auto_update/README.rst +++ b/module_auto_update/README.rst @@ -7,7 +7,7 @@ Module Auto Update !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:e654a3f7da52461fd3ef48a79370ef83879c11319580f8d85cb3f9c5cd1da4d4 + !! source digest: sha256:7776532fffefae62af6ccc66d95c3644cd9180ccf04c027e6e1f2afd8de58c46 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png @@ -107,6 +107,8 @@ Contributors * Stéphane Bidoul (https://acsone.eu) * Eric Antones * Manuel Engel +* PyTech SRL +* Ooops404 Maintainers ~~~~~~~~~~~ diff --git a/module_auto_update/__init__.py b/module_auto_update/__init__.py index c5d48b349d3..a2276d08d24 100644 --- a/module_auto_update/__init__.py +++ b/module_auto_update/__init__.py @@ -1,4 +1,5 @@ # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). from . import models +from . import wizard from .hooks import uninstall_hook diff --git a/module_auto_update/__manifest__.py b/module_auto_update/__manifest__.py index 4502968a148..923c165e527 100644 --- a/module_auto_update/__manifest__.py +++ b/module_auto_update/__manifest__.py @@ -17,6 +17,9 @@ "installable": True, "uninstall_hook": "uninstall_hook", "depends": ["base"], - "data": ["views/ir_module_module.xml"], + "data": [ + "security/ir.model.access.csv", + "wizard/module_auto_update_views.xml", + ], "development_status": "Production/Stable", } diff --git a/module_auto_update/readme/CONTRIBUTORS.rst b/module_auto_update/readme/CONTRIBUTORS.rst index d62dca127ee..17ab2c3b643 100644 --- a/module_auto_update/readme/CONTRIBUTORS.rst +++ b/module_auto_update/readme/CONTRIBUTORS.rst @@ -4,3 +4,5 @@ * Stéphane Bidoul (https://acsone.eu) * Eric Antones * Manuel Engel +* PyTech SRL +* Ooops404 diff --git a/module_auto_update/security/ir.model.access.csv b/module_auto_update/security/ir.model.access.csv new file mode 100644 index 00000000000..8005cf06784 --- /dev/null +++ b/module_auto_update/security/ir.model.access.csv @@ -0,0 +1,2 @@ +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" +access_module_auto_update,access_module_auto_update,model_module_auto_update,base.group_no_one,1,1,1,1 diff --git a/module_auto_update/static/description/index.html b/module_auto_update/static/description/index.html index ab997c61341..3a8378d148d 100644 --- a/module_auto_update/static/description/index.html +++ b/module_auto_update/static/description/index.html @@ -367,7 +367,7 @@

Module Auto Update

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:e654a3f7da52461fd3ef48a79370ef83879c11319580f8d85cb3f9c5cd1da4d4 +!! source digest: sha256:7776532fffefae62af6ccc66d95c3644cd9180ccf04c027e6e1f2afd8de58c46 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Production/Stable License: LGPL-3 OCA/server-tools Translate me on Weblate Try me on Runboat

This addon provides mechanisms to compute sha1 hashes of installed addons, @@ -449,6 +449,8 @@

Contributors

  • Stéphane Bidoul <stephane.bidoul@acsone.eu> (https://acsone.eu)
  • Eric Antones <eantones@nuobit.com>
  • Manuel Engel <manuel.engel@initos.com>
  • +
  • PyTech SRL <info@pytech.it>
  • +
  • Ooops404 <info@ooops404.com>
  • diff --git a/module_auto_update/views/ir_module_module.xml b/module_auto_update/views/ir_module_module.xml deleted file mode 100644 index 05be0e927be..00000000000 --- a/module_auto_update/views/ir_module_module.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - Auto-Upgrade Modules - ir.actions.server - - code - - action = model.upgrade_changed_checksum() - - - - diff --git a/module_auto_update/wizard/__init__.py b/module_auto_update/wizard/__init__.py new file mode 100644 index 00000000000..5b239519af3 --- /dev/null +++ b/module_auto_update/wizard/__init__.py @@ -0,0 +1 @@ +from . import module_auto_update diff --git a/module_auto_update/wizard/module_auto_update.py b/module_auto_update/wizard/module_auto_update.py new file mode 100644 index 00000000000..fa236af9fab --- /dev/null +++ b/module_auto_update/wizard/module_auto_update.py @@ -0,0 +1,26 @@ +from odoo import fields, models + + +class ModuleAutoUpdate(models.TransientModel): + _name = "module.auto.update" + _description = "Auto-Upgrade Modules" + + modules_to_update_ids = fields.Many2many( + "ir.module.module", string="Modules to Update", readonly=True + ) + + def action_get_modules_to_update(self): + self.modules_to_update_ids = self.env[ + "ir.module.module" + ]._get_modules_with_changed_checksum() + return { + "type": "ir.actions.act_window", + "res_model": "module.auto.update", + "view_mode": "form", + "res_id": self.id, + "views": [(False, "form")], + "target": "new", + } + + def action_upgrade_module(self): + self.env["ir.module.module"].upgrade_changed_checksum() diff --git a/module_auto_update/wizard/module_auto_update_views.xml b/module_auto_update/wizard/module_auto_update_views.xml new file mode 100644 index 00000000000..45ade6096d6 --- /dev/null +++ b/module_auto_update/wizard/module_auto_update_views.xml @@ -0,0 +1,56 @@ + + + + Module Upgrade + module.auto.update + +
    +

    Are you sure you want to launch module auto-update?

    +