Browse Source

[IMP] Combining methods

pull/506/head
Maxime Chambreuil 8 years ago
parent
commit
68ce176f51
  1. 31
      base_export_manager/models/res_users.py

31
base_export_manager/models/res_users.py

@ -9,23 +9,14 @@ from openerp import api, models
class ResUsers(models.Model):
_inherit = 'res.users'
@api.v7
def get_export_models(self, cr, uid):
return self.fetch_export_models(cr, uid)
@api.v8
def get_export_models(self):
uid = self.id or self.env.uid
return self.fetch_export_models(self.env.cr, uid)
def fetch_export_models(self, cr, uid):
groups_id = [group.id for group in self.browse(cr, uid, uid).groups_id]
accessobj = self.pool['ir.model.access']
accessobj_ids = accessobj.search(cr, uid, [('perm_export', '=', True),
('group_id', 'in',
groups_id)])
model_names = [access_obj.model_id.model for access_obj in
accessobj.browse(cr, uid, accessobj_ids)]
# Make distinct value in list
model_names = list(set(model_names))
return model_names
@api.model
def fetch_export_models(self):
accessobj = self.env['ir.model.access']
accessobj_ids = accessobj.search([
('perm_export', '=', True),
('group_id', 'in', self.env.user.groups_id.ids),
])
model_names = [
access_obj.model_id.model for access_obj in accessobj_ids
]
return list(set(model_names))
Loading…
Cancel
Save