-
Notifications
You must be signed in to change notification settings - Fork 1
/
base.py
41 lines (32 loc) · 1.47 KB
/
base.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- coding: utf-8 -*-
from osv import osv
from openerp import SUPERUSER_ID
def name_selection_groups(ids): return 'sel_groups_' + '_'.join(map(str, ids))
def name_boolean_group(id): return 'in_group_' + str(id)
class res_users(osv.osv):
_inherit = 'res.users'
def init(self, cr):
for app, kind, gs in self.pool.get('res.groups').get_groups_by_application(cr, 1):
try:
if kind == 'selection':
self.write(cr, 1 , [SUPERUSER_ID],{name_selection_groups(map(int, gs)):gs[-1].id})
else:
for g in gs:
self.write(cr, 1 , [SUPERUSER_ID],{name_boolean_group(g.id):True})
except:
continue
res_users()
class module(osv.osv):
_inherit = "ir.module.module"
def button_immediate_install(self, cr, uid, ids, context=None):
res = super(module, self).button_immediate_install(cr, uid, ids, context=context)
for app, kind, gs in self.pool.get('res.groups').get_groups_by_application(cr, SUPERUSER_ID):
try:
if kind == 'selection':
self.pool.get('res.users').write(cr, SUPERUSER_ID , [SUPERUSER_ID],{name_selection_groups(map(int, gs)):gs[-1].id})
else:
for g in gs:
self.pool.get('res.users').write(cr, SUPERUSER_ID , [SUPERUSER_ID],{name_boolean_group(g.id):True})
except :
continue
return res