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. -->
+
+