diff --git a/CHANGELOG b/CHANGELOG
index e4dbc52522..27ef81acfe 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,4 @@
+* Allow sharing view searches
* Allow overriding digits in Lang.currency and Report.format_currency
* Add record name in report filename
* Add deletable and writable state from ir.rule to read
diff --git a/trytond/ir/ui/view.py b/trytond/ir/ui/view.py
index 9d1e1448c6..176ac6bf49 100644
--- a/trytond/ir/ui/view.py
+++ b/trytond/ir/ui/view.py
@@ -383,8 +383,7 @@ class ViewSearch(ModelSQL, ModelView):
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')
+ user = fields.Many2One('res.user', 'User', ondelete='CASCADE')
@classmethod
def __setup__(cls):
@@ -393,20 +392,29 @@ class ViewSearch(ModelSQL, ModelView):
'get_search': RPC(),
})
+ @classmethod
+ def __register__(cls, module):
+ super().__register__(module)
+ table_h = cls.__table_handler__(module)
+
+ # Migration from 5.6: remove user required
+ table_h.not_null_action('user', 'remove')
+
@staticmethod
def default_user():
return Transaction().user
@classmethod
- def get_search(cls, user_id=None):
- if user_id is None:
- user_id = Transaction().user
+ def get_search(cls):
decoder = PYSONDecoder()
- searches = cls.search([
- ('user', '=', user_id),
- ], order=[('model', 'ASC'), ('name', 'ASC')])
+ searches = cls.search_read(
+ [], order=[('model', 'ASC'), ('name', 'ASC')],
+ fields_names=['id', 'name', 'model', 'domain', '_delete'])
result = {}
for search in searches:
- result.setdefault(search.model, []).append(
- (search.id, search.name, decoder.decode(search.domain)))
+ result.setdefault(search['model'], []).append((
+ search['id'],
+ search['name'],
+ decoder.decode(search['domain']),
+ search['_delete']))
return result
diff --git a/trytond/res/ir.xml b/trytond/res/ir.xml
index 98c630cf5f..6b80fe87bc 100644
--- a/trytond/res/ir.xml
+++ b/trytond/res/ir.xml
@@ -836,6 +836,24 @@ this repository contains the full copyright notices and license terms. -->
+
+ Common view search
+
+
+
+
+
+
+
+
+
+
+
+
+
Any view search