Merge lp:~david-leach/openobject-server/7.0-server-serveraction-groups into lp:openobject-server/7.0

Proposed by David Leach
Status: Needs review
Proposed branch: lp:~david-leach/openobject-server/7.0-server-serveraction-groups
Merge into: lp:openobject-server/7.0
Diff against target: 52 lines (+11/-2)
3 files modified
openerp/addons/base/ir/ir_actions.py (+1/-0)
openerp/addons/base/ir/ir_actions.xml (+3/-0)
openerp/addons/base/ir/ir_values.py (+7/-2)
To merge this branch: bzr merge lp:~david-leach/openobject-server/7.0-server-serveraction-groups
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+220720@code.launchpad.net

Description of the change

Assigning permissions on actions based on groups is only currently enabled for wizard, report, and window actions. This adds support for server actions as well, using the same method as the three others.

To post a comment you must log in.

Unmerged revisions

5308. By David Leach

[IMP] Allow setting permissions on server actions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerp/addons/base/ir/ir_actions.py'
2--- openerp/addons/base/ir/ir_actions.py 2014-01-07 17:20:10 +0000
3+++ openerp/addons/base/ir/ir_actions.py 2014-05-22 20:55:51 +0000
4@@ -487,6 +487,7 @@
5 'loop_action':fields.many2one('ir.actions.server', 'Loop Action', help="Select the action that will be executed. Loop action will not be avaliable inside loop."),
6 'expression':fields.char('Loop Expression', size=512, help="Enter the field/expression that will return the list. E.g. select the sale order in Object, and you can have loop on the sales order line. Expression = `object.order_line`."),
7 'copy_object': fields.reference('Copy Of', selection=_select_objects, size=256),
8+ 'groups_id': fields.many2many('res.groups', 'res_groups_action_rel', 'uid', 'gid', 'Groups'),
9 }
10 _defaults = {
11 'state': 'dummy',
12
13=== modified file 'openerp/addons/base/ir/ir_actions.xml'
14--- openerp/addons/base/ir/ir_actions.xml 2012-12-05 16:00:15 +0000
15+++ openerp/addons/base/ir/ir_actions.xml 2014-05-22 20:55:51 +0000
16@@ -386,6 +386,9 @@
17 <field name="child_ids"/>
18 <label string="Only one client action will be executed, last client action will be considered in case of multiple client actions." align="0.0"/>
19 </page>
20+ <page string="Security">
21+ <field name="groups_id"/>
22+ </page>
23 </notebook>
24 <field name="type" readonly="1"/>
25 </form>
26
27=== modified file 'openerp/addons/base/ir/ir_values.py'
28--- openerp/addons/base/ir/ir_values.py 2014-05-09 13:04:12 +0000
29+++ openerp/addons/base/ir/ir_values.py 2014-05-22 20:55:51 +0000
30@@ -37,6 +37,12 @@
31 "tree_but_action", # deprecated: same as tree_but_open
32 ]
33
34+PERMISSION_ACTION_MODELS = [
35+ "ir.actions.report.xml",
36+ "ir.actions.act_window",
37+ "ir.actions.wizard",
38+ "ir.actions.server",
39+ ]
40
41 class ir_values(osv.osv):
42 """Holds internal model-specific action bindings and user-defined default
43@@ -410,8 +416,7 @@
44 try:
45 action_def = self.pool.get(action_model).read(cr, uid, int(id), fields, context)
46 if action_def:
47- if action_model in ('ir.actions.report.xml','ir.actions.act_window',
48- 'ir.actions.wizard'):
49+ if action_model in PERMISSION_ACTION_MODELS:
50 groups = action_def.get('groups_id')
51 if groups:
52 cr.execute('SELECT 1 FROM res_groups_users_rel WHERE gid IN %s AND uid=%s',