diff --git a/CHANGELOG b/CHANGELOG index 1aecaa2353..2c478dcc82 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Ensure that all buttons are registered in ir.model.button * Make trytond-admin ask for admin email * Add option to set admin email with trytond-admin * Add option to reset admin password with trytond-admin diff --git a/doc/topics/views/index.rst b/doc/topics/views/index.rst index 28b0218897..5eddb7e61e 100644 --- a/doc/topics/views/index.rst +++ b/doc/topics/views/index.rst @@ -333,8 +333,6 @@ button Display a button. - * ``string``: The string that will be displayed inside the button. - * ``name``: The name of the function that will be called. The function must have this syntax: @@ -343,6 +341,16 @@ Display a button. The function may return an `ir.action` id or one of those client side action keywords: + * ``string``: The string that will be displayed inside the button. + + * ``confirm``: A string that will be shown in order to request + confirmation when clicking the button. + + * ``help``: see in common-attributes-help_. + +The button should be registered on ``ir.model.button`` where the default value +of the ``string``, ``confirm`` and ``help`` attributes can be can be defined. + .. _topics-views-client-actions: * ``new``: to create a new record diff --git a/trytond/ir/cron.xml b/trytond/ir/cron.xml index cc1ca464f5..3f81eca94e 100644 --- a/trytond/ir/cron.xml +++ b/trytond/ir/cron.xml @@ -35,5 +35,11 @@ this repository contains the full copyright notices and license terms. --> + + + run_once + Run Once + + diff --git a/trytond/ir/model.py b/trytond/ir/model.py index 05d0fc9f86..266b1308ff 100644 --- a/trytond/ir/model.py +++ b/trytond/ir/model.py @@ -708,6 +708,10 @@ class ModelButton(ModelSQL, ModelView): "Model Button" __name__ = 'ir.model.button' name = fields.Char('Name', required=True, readonly=True) + string = fields.Char("Label", translate=True) + help = fields.Text("Help", translate=True) + confirm = fields.Text("Confirm", translate=True, + help="Text to ask user confirmation when clicking the button.") model = fields.Many2One('ir.model', 'Model', required=True, readonly=True, ondelete='CASCADE', select=True) groups = fields.Many2Many('ir.model.button-res.group', 'button', 'group', @@ -732,6 +736,8 @@ class ModelButton(ModelSQL, ModelView): ], depends=['model', 'id']) _reset_cache = Cache('ir.model.button.reset') + _view_attributes_cache = Cache( + 'ir.model.button.view_attributes', context=False) @classmethod def __setup__(cls): @@ -750,6 +756,7 @@ class ModelButton(ModelSQL, ModelView): cls._groups_cache.clear() cls._rules_cache.clear() cls._reset_cache.clear() + cls._view_attributes_cache.clear() return result @classmethod @@ -759,6 +766,7 @@ class ModelButton(ModelSQL, ModelView): cls._groups_cache.clear() cls._rules_cache.clear() cls._reset_cache.clear() + cls._view_attributes_cache.clear() @classmethod def delete(cls, buttons): @@ -767,6 +775,7 @@ class ModelButton(ModelSQL, ModelView): cls._groups_cache.clear() cls._rules_cache.clear() cls._reset_cache.clear() + cls._view_attributes_cache.clear() @classmethod def copy(cls, buttons, default=None): @@ -838,6 +847,29 @@ class ModelButton(ModelSQL, ModelView): cls._reset_cache.set(key, reset) return reset + @classmethod + def get_view_attributes(cls, model, name): + "Return the view attributes of the named button of the model" + key = (model, name, Transaction().language) + attributes = cls._view_attributes_cache.get(key) + if attributes is not None: + return attributes + buttons = cls.search([ + ('model.model', '=', model), + ('name', '=', name), + ]) + if not buttons: + attributes = {} + else: + button, = buttons + attributes = { + 'string': button.string, + 'help': button.help, + 'confirm': button.confirm, + } + cls._view_attributes_cache.set(key, attributes) + return attributes + class ModelButtonRule(ModelSQL, ModelView): "Model Button Rule" diff --git a/trytond/ir/model.xml b/trytond/ir/model.xml index bb03999fcb..b90704a794 100644 --- a/trytond/ir/model.xml +++ b/trytond/ir/model.xml @@ -297,6 +297,11 @@ this repository contains the full copyright notices and license terms. --> + + sync + Sync + + diff --git a/trytond/ir/module.xml b/trytond/ir/module.xml index 037d02a300..6ae517afb3 100644 --- a/trytond/ir/module.xml +++ b/trytond/ir/module.xml @@ -35,6 +35,37 @@ this repository contains the full copyright notices and license terms. --> + + activate + Mark for Activation + + + + activate_cancel + Cancel Activation + + + + deactivate + Mark for Deactivation (beta) + + + + deactivate_cancel + Cancel Deactivation + + + + upgrade + Mark for Upgrade + + + + upgrade_cancel + Cancel Upgrade + + + ir.module.dependency form diff --git a/trytond/ir/ui/form.rnc b/trytond/ir/ui/form.rnc index 9151c60ca1..f8ca912e12 100644 --- a/trytond/ir/ui/form.rnc +++ b/trytond/ir/ui/form.rnc @@ -138,8 +138,7 @@ attlist.newline &= empty button = element button { attlist.button, empty } attlist.button &= [ a:defaultValue = "1" ] attribute colspan { text }? attlist.button &= attribute help { text }? -attlist.button &= - [ a:defaultValue = "Unknown" ] attribute string { text }? +attlist.button &= attribute string { text }? attlist.button &= attribute icon { text }? attlist.button &= attribute confirm { text }? attlist.button &= attribute name { text } diff --git a/trytond/ir/ui/form.rng b/trytond/ir/ui/form.rng index 87fb51e195..ca6ba63046 100644 --- a/trytond/ir/ui/form.rng +++ b/trytond/ir/ui/form.rng @@ -541,7 +541,7 @@ - + diff --git a/trytond/ir/ui/tree.rnc b/trytond/ir/ui/tree.rnc index 4b3ece8835..f85383b545 100644 --- a/trytond/ir/ui/tree.rnc +++ b/trytond/ir/ui/tree.rnc @@ -68,8 +68,7 @@ attlist.affix &= ( attribute name { text } | attribute id { text } ) attlist.affix &= attribute icon { text }? button = element button { attlist.button, empty } attlist.button &= attribute help { text }? -attlist.button &= - [ a:defaultValue = "Unknown" ] attribute string { text }? +attlist.button &= attribute string { text }? attlist.button &= attribute confirm { text }? attlist.button &= attribute name { text } attlist.button &= attribute states { text }? diff --git a/trytond/ir/ui/tree.rng b/trytond/ir/ui/tree.rng index 028ffa820f..edd4fc7b74 100644 --- a/trytond/ir/ui/tree.rng +++ b/trytond/ir/ui/tree.rng @@ -234,7 +234,7 @@ - + diff --git a/trytond/ir/ui/view.xml b/trytond/ir/ui/view.xml index e3d3f97753..e4c61ea84e 100644 --- a/trytond/ir/ui/view.xml +++ b/trytond/ir/ui/view.xml @@ -38,6 +38,11 @@ this repository contains the full copyright notices and license terms. --> + + show + Show + + ir.ui.view_tree_width diff --git a/trytond/ir/view/cron_form.xml b/trytond/ir/view/cron_form.xml index d9a49c1c8d..7fab5e1f8d 100644 --- a/trytond/ir/view/cron_form.xml +++ b/trytond/ir/view/cron_form.xml @@ -20,7 +20,7 @@ this repository contains the full copyright notices and license terms. -->