From 864b16a5e8ef487ef7f972b4d544ac4a1771e5f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 16 Nov 2012 20:11:51 +0100 Subject: [PATCH] Add ViewSearch review590002 --- CHANGELOG | 1 + trytond/ir/__init__.py | 1 + trytond/ir/ui/view.py | 40 +++++++++++++++++++++++-- trytond/ir/ui/view.xml | 30 +++++++++++++++++++ trytond/ir/view/ui_view_search_form.xml | 13 ++++++++ trytond/ir/view/ui_view_search_list.xml | 7 +++++ trytond/res/ir.xml | 34 +++++++++++++++++++++ 7 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 trytond/ir/view/ui_view_search_form.xml create mode 100644 trytond/ir/view/ui_view_search_list.xml diff --git a/CHANGELOG b/CHANGELOG index 3a42a97965..ea517ea023 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Add ViewSearch * Add domains on Action Window Version 2.6.0 - 2012-10-22 diff --git a/trytond/ir/__init__.py b/trytond/ir/__init__.py index 708db4013f..355e46a65e 100644 --- a/trytond/ir/__init__.py +++ b/trytond/ir/__init__.py @@ -40,6 +40,7 @@ def register(): ViewShortcut, ViewTreeWidth, ViewTreeExpandedState, + ViewSearch, Icon, Property, Action, diff --git a/trytond/ir/ui/view.py b/trytond/ir/ui/view.py index cf5d77b4ea..80a1456125 100644 --- a/trytond/ir/ui/view.py +++ b/trytond/ir/ui/view.py @@ -6,7 +6,7 @@ from lxml import etree from difflib import SequenceMatcher from trytond.model import ModelView, ModelSQL, fields from trytond.backend import TableHandler -from trytond.pyson import CONTEXT, Eval, Bool +from trytond.pyson import CONTEXT, Eval, Bool, PYSONDecoder from trytond.tools import safe_eval, file_open from trytond.transaction import Transaction from trytond.wizard import Wizard, StateView, StateAction, Button @@ -16,7 +16,7 @@ from trytond.rpc import RPC __all__ = [ 'View', 'ShowViewStart', 'ShowView', 'ViewShortcut', 'ShowView', - 'OpenShortcut', 'ViewTreeWidth', 'ViewTreeExpandedState', + 'OpenShortcut', 'ViewTreeWidth', 'ViewTreeExpandedState', 'ViewSearch', ] @@ -529,3 +529,39 @@ class ViewTreeExpandedState(ModelSQL, ModelView): except ValueError: return '[]' return cls(expanded_info).nodes + + +class ViewSearch(ModelSQL, ModelView): + "View Search" + __name__ = 'ir.ui.view_search' + + name = fields.Char('Name', required=True) + model = fields.Char('Model', required=True) + domain = fields.Char('Domain', help="The PYSON domain") + user = fields.Many2One('res.user', 'User', required=True, + ondelete='CASCADE') + + @classmethod + def __setup__(cls): + super(ViewSearch, cls).__setup__() + cls.__rpc__.update({ + 'get_search': RPC(), + }) + + @staticmethod + def default_user(): + return Transaction().user + + @classmethod + def get_search(cls, user_id=None): + if user_id is None: + user_id = Transaction().user + decoder = PYSONDecoder() + searches = cls.search([ + ('user', '=', user_id), + ], order=[('model', 'ASC'), ('name', 'ASC')]) + result = {} + for search in searches: + result.setdefault(search.model, []).append( + (search.id, search.name, decoder.decode(search.domain))) + return result diff --git a/trytond/ir/ui/view.xml b/trytond/ir/ui/view.xml index 226c6781ee..d946987b53 100644 --- a/trytond/ir/ui/view.xml +++ b/trytond/ir/ui/view.xml @@ -149,5 +149,35 @@ this repository contains the full copyright notices and license terms. --> + + + ir.ui.view_search + form + ui_view_search_form + + + ir.ui.view_search + tree + ui_view_search_list + + + View Search + ir.action.act_window + ir.ui.view_search + + + + + + + + + + + + diff --git a/trytond/ir/view/ui_view_search_form.xml b/trytond/ir/view/ui_view_search_form.xml new file mode 100644 index 0000000000..079433e9dd --- /dev/null +++ b/trytond/ir/view/ui_view_search_form.xml @@ -0,0 +1,13 @@ + + +
+