diff --git a/CHANGELOG b/CHANGELOG index 040a71e3a7..8dfef21aef 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Add wizard to show views * Switched from .csv to .po for translations * Search on Many2One fields include inactive records * Change select on fields into Boolean diff --git a/trytond/ir/ui/view.py b/trytond/ir/ui/view.py index e20f09c7f2..72a7422d45 100644 --- a/trytond/ir/ui/view.py +++ b/trytond/ir/ui/view.py @@ -233,6 +233,57 @@ class View(ModelSQL, ModelView): View() +class ShowViewInit(ModelView): + 'Show view init' + _name = 'ir.ui.view.show.init' + +ShowViewInit() + + +class ShowView(Wizard): + 'Show view' + _name = 'ir.ui.view.show' + + states = { + 'init': { + 'result': { + 'type': 'form', + 'object': 'ir.ui.view.show.init', + 'state': [ + ('end', 'Close', 'tryton-cancel', True), + ], + }, + }, + } + + def __init__(self): + super(ShowView, self).__init__() + self._error_messages.update({ + 'view_type': 'Only "form" view can be shown!', + }) + + def execute(self, wiz_id, data, state='init'): + pool = Pool() + view_obj = pool.get('ir.ui.view') + result = super(ShowView, self).execute(wiz_id, data, state=state) + view = view_obj.browse(data['id']) + view_id = view.id + view_type = view.type + if view.inherit: + view_id = view.inherit.id + view_type = view.inherit.type + if view_type != 'form': + self.raise_user_error('view_type') + model_obj = pool.get(view.model) + fields_view = model_obj.fields_view_get(view_id=view.id) + result['fields'] = fields_view['fields'] + result['arch'] = fields_view['arch'] + result['object'] = view.model + return result + +ShowView() + + class ViewShortcut(ModelSQL, ModelView): "View shortcut" _name = 'ir.ui.view_sc' diff --git a/trytond/ir/ui/view.xml b/trytond/ir/ui/view.xml index 39c75a49f6..9f18b4cd0a 100644 --- a/trytond/ir/ui/view.xml +++ b/trytond/ir/ui/view.xml @@ -3,6 +3,12 @@ this repository contains the full copyright notices and license terms. --> + + + Show View + ir.ui.view.show + + ir.ui.view form @@ -23,6 +29,11 @@ this repository contains the full copyright notices and license terms. --> +