merge
This commit is contained in:
commit
ae5d192d2a
4 files changed
+54
-35
No files matched your search
@@ -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
|
||||
---
|
||||
|
||||
|
||||
+35
-29
@@ -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()
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -440,6 +440,22 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="operand">False</field>
|
||||
<field name="rule_group" ref="rule_group_action"/>
|
||||
</record>
|
||||
<record model="ir.rule.group" id="rule_group_action_keyword">
|
||||
<field name="model" search="[('model', '=', 'ir.action.keyword')]"/>
|
||||
<field name="global_p" eval="True"/>
|
||||
</record>
|
||||
<record model="ir.rule" id="rule_action_keyword1">
|
||||
<field name="field" search="[('name', '=', 'groups'),('model.model', '=', 'ir.action.keyword')]"/>
|
||||
<field name="operator">in</field>
|
||||
<field name="operand">User/Groups</field>
|
||||
<field name="rule_group" ref="rule_group_action_keyword"/>
|
||||
</record>
|
||||
<record model="ir.rule" id="rule_action_keyword2">
|
||||
<field name="field" search="[('name', '=', 'groups'),('model.model', '=', 'ir.action.keyword')]"/>
|
||||
<field name="operator">=</field>
|
||||
<field name="operand">False</field>
|
||||
<field name="rule_group" ref="rule_group_action_keyword"/>
|
||||
</record>
|
||||
<record model="ir.action-res.group" id="act_module_install_upgrade_group_admin">
|
||||
<field name="action" ref="ir.act_module_install_upgrade"/>
|
||||
<field name="group" ref="group_admin"/>
|
||||
|
||||
Reference in new issue
Block a user