details: https://code.tryton.org/tryton/commit/72376d43b60f
branch: default
user: Cédric Krier <[email protected]>
date: Fri Jul 24 14:39:41 2026 +0200
description:
Disable buttons to upgrade/update modules if there is no action to
perform
Closes #4960
diffstat:
trytond/trytond/ir/module.py | 27 +++++++--
trytond/trytond/ir/view/module_activate_upgrade_start_form.xml | 11 +---
2 files changed, 20 insertions(+), 18 deletions(-)
diffs (90 lines):
diff -r 53f956b55465 -r 72376d43b60f trytond/trytond/ir/module.py
--- a/trytond/trytond/ir/module.py Thu Aug 06 15:59:39 2026 +0200
+++ b/trytond/trytond/ir/module.py Fri Jul 24 14:39:41 2026 +0200
@@ -82,7 +82,11 @@
['to activate', 'to remove', 'to upgrade']),
'depends': ['state'],
},
- 'apply': {},
+ 'apply': {
+ 'readonly': ~Eval('state').in_(
+ ['to upgrade', 'to remove', 'to activate']),
+ 'depends': ['state'],
+ },
})
@staticmethod
@@ -240,7 +244,10 @@
@classmethod
@ModelView.button_action('ir.act_module_activate_upgrade')
def apply(cls, modules):
- pass
+ return {
+ # Set keyword to prevent record names to be appended
+ 'keyword': 'form_relate',
+ }
@classmethod
def update_list(cls):
@@ -424,7 +431,9 @@
class ModuleActivateUpgradeStart(ModelView):
__name__ = 'ir.module.activate_upgrade.start'
- module_info = fields.Text('Modules to update', readonly=True)
+ modules = fields.Many2Many(
+ 'ir.module', None, None,
+ "Modules to Activate / Upgrade", readonly=True)
class ModuleActivateUpgradeDone(ModelView):
@@ -437,7 +446,10 @@
start = StateView('ir.module.activate_upgrade.start',
'ir.module_activate_upgrade_start_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
- Button('Start Upgrade', 'upgrade', 'tryton-ok', default=True),
+ Button("OK", 'upgrade', 'tryton-ok', default=True,
+ states={
+ 'readonly': ~Eval('modules'),
+ }),
])
upgrade = StateTransition()
done = StateView('ir.module.activate_upgrade.done',
@@ -453,16 +465,15 @@
with Transaction().new_transaction():
super().check_access()
- @staticmethod
- def default_start(fields):
+ @classmethod
+ def default_start(cls, fields):
pool = Pool()
Module = pool.get('ir.module')
modules = Module.search([
('state', 'in', ['to upgrade', 'to remove', 'to activate']),
])
return {
- 'module_info': '\n'.join(x.name + ': ' + x.state
- for x in modules),
+ 'modules': [m.id for m in modules],
}
def __init__(self, session_id):
diff -r 53f956b55465 -r 72376d43b60f
trytond/trytond/ir/view/module_activate_upgrade_start_form.xml
--- a/trytond/trytond/ir/view/module_activate_upgrade_start_form.xml Thu Aug
06 15:59:39 2026 +0200
+++ b/trytond/trytond/ir/view/module_activate_upgrade_start_form.xml Fri Jul
24 14:39:41 2026 +0200
@@ -2,14 +2,5 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form col="2">
- <image name="tryton-info" xexpand="0" xfill="0"/>
- <group col="1" id="labels" yalign="0.5">
- <label string="Your system will be upgraded." id="upgraded"
- xalign="0.0" xexpand="1"/>
- <label string="Note that this operation may take a few minutes."
- id="operation"
- xalign="0.0" xexpand="1"/>
- </group>
- <separator name="module_info" colspan="2"/>
- <field name="module_info" colspan="2"/>
+ <field name="modules" colspan="2"/>
</form>