diff --git a/doc/ref/models/fields.rst b/doc/ref/models/fields.rst
index a61767231c..4c1a9f8f24 100644
--- a/doc/ref/models/fields.rst
+++ b/doc/ref/models/fields.rst
@@ -205,11 +205,6 @@ A single line string field.
This method must return a list of string that will populate the
ComboboxEntry in the client.
-.. warning::
- Note that you may need to set :attr:`Field.loading` to ``lazy``
- when :attr:`Char.translate` is ``True``.
-..
-
Sha
---
diff --git a/trytond/ir/action.py b/trytond/ir/action.py
index 26e6625563..c8c8d05dca 100644
--- a/trytond/ir/action.py
+++ b/trytond/ir/action.py
@@ -3,13 +3,14 @@
import base64
import os
from operator import itemgetter
+from collections import defaultdict
+
from ..model import ModelView, ModelSQL, ModelStorage, fields
from ..tools import file_open, safe_eval
from ..backend import TableHandler
from ..pyson import PYSONEncoder, CONTEXT, PYSON
from ..transaction import Transaction
from ..pool import Pool
-from ..exceptions import UserError
from ..cache import Cache
EMAIL_REFKEYS = set(('cc', 'to', 'subject'))
@@ -62,13 +63,8 @@ class Action(ModelSQL, ModelView):
action = action_obj.browse(action_id2[0])
return action.action.id
- def get_action_values(self, type_, action_id):
+ def get_action_values(self, type_, action_ids):
action_obj = Pool().get(type_)
- action_id = action_obj.search([
- ('action', '=', action_id),
- ])
- if not action_id:
- return
columns = set(action_obj._columns.keys()
+ action_obj._inherit_fields.keys())
columns.add('icon.rec_name')
@@ -79,7 +75,7 @@ class Action(ModelSQL, ModelView):
elif type_ == 'ir.action.act_window':
to_remove = ('domain', 'context', 'search_value')
columns.difference_update(to_remove)
- return action_obj.read(action_id[0], list(columns))
+ return action_obj.read(action_ids, list(columns))
Action()
@@ -99,6 +95,8 @@ class ActionKeyword(ModelSQL, ModelView):
model = fields.Reference('Model', selection='models_get')
action = fields.Many2One('ir.action', 'Action',
ondelete='CASCADE', select=True)
+ groups = fields.Function(fields.One2Many('res.group', None, 'Groups'),
+ 'get_groups', searcher='search_groups')
def __init__(self):
super(ActionKeyword, self).__init__()
@@ -116,6 +114,15 @@ class ActionKeyword(ModelSQL, ModelView):
table = TableHandler(Transaction().cursor, self, module_name)
table.index_action(['keyword', 'model'], 'add')
+ def get_groups(self, ids, name):
+ groups = {}
+ for keyword in self.browse(ids):
+ groups[keyword.id] = [g.id for g in keyword.action.groups]
+ return groups
+
+ def search_groups(self, name, clause):
+ return [('action.groups',) + tuple(clause[1:])]
+
def check_wizard_model(self, ids):
pool = Pool()
action_wizard_obj = pool.get('ir.action.wizard')
@@ -225,31 +232,30 @@ class ActionKeyword(ModelSQL, ModelView):
def get_keyword(self, keyword, value):
pool = Pool()
action_obj = pool.get('ir.action')
- res = []
+ keywords = []
model, model_id = value
- action_keyword_ids = []
- if model_id >= 0:
- action_keyword_ids = self.search([
- ('keyword', '=', keyword),
- ('model', '=', model + ',' + str(model_id)),
- ])
- action_keyword_ids.extend(self.search([
+ clause = [
('keyword', '=', keyword),
('model', '=', model + ',-1'),
- ]))
- for action_keyword_id in action_keyword_ids:
- action_keyword = self.browse(action_keyword_id)
- try:
- type_ = action_keyword.action.type
- except UserError:
- continue
- values = action_obj.get_action_values(type_,
- action_keyword.action.id)
- if values:
- res.append(values)
- res.sort(key=itemgetter('name'))
- return res
+ ]
+ if model_id >= 0:
+ clause = ['OR',
+ clause,
+ [
+ ('keyword', '=', keyword),
+ ('model', '=', model + ',' + str(model_id)),
+ ],
+ ]
+ action_keyword_ids = self.search(clause, order=[])
+ types = defaultdict(list)
+ for action_keyword in self.browse(action_keyword_ids):
+ type_ = action_keyword.action.type
+ types[type_].append(action_keyword.action.id)
+ for type_, action_ids in types.iteritems():
+ keywords.extend(action_obj.get_action_values(type_, action_ids))
+ keywords.sort(key=itemgetter('name'))
+ return keywords
ActionKeyword()
diff --git a/trytond/model/fields/char.py b/trytond/model/fields/char.py
index 3e2d56eb22..5f9f0bdb8a 100644
--- a/trytond/model/fields/char.py
+++ b/trytond/model/fields/char.py
@@ -18,12 +18,14 @@ class Char(Field):
def __init__(self, string='', size=None, help='', required=False,
readonly=False, domain=None, states=None, translate=False,
select=False, on_change=None, on_change_with=None, depends=None,
- order_field=None, context=None, loading='eager',
+ order_field=None, context=None, loading=None,
autocomplete=None):
'''
:param translate: A boolean. If ``True`` the field is translatable.
:param size: A integer. If set defines the maximum size of the values.
'''
+ if loading is None:
+ loading = 'lazy' if translate else 'eager'
super(Char, self).__init__(string=string, help=help, required=required,
readonly=readonly, domain=domain, states=states, select=select,
on_change=on_change, on_change_with=on_change_with,
diff --git a/trytond/res/ir.xml b/trytond/res/ir.xml
index 31ca9d7bb5..3cd68866fa 100644
--- a/trytond/res/ir.xml
+++ b/trytond/res/ir.xml
@@ -440,6 +440,22 @@ this repository contains the full copyright notices and license terms. -->
False
+
+
+
+
+
+
+ in
+ User/Groups
+
+
+
+
+ =
+ False
+
+