|
@ -32,7 +32,6 @@ class ResUsersRole(models.Model): |
|
|
string="Associated category", |
|
|
string="Associated category", |
|
|
help="Associated group's category") |
|
|
help="Associated group's category") |
|
|
|
|
|
|
|
|
@api.multi |
|
|
|
|
|
@api.depends('line_ids.user_id') |
|
|
@api.depends('line_ids.user_id') |
|
|
def _compute_user_ids(self): |
|
|
def _compute_user_ids(self): |
|
|
for role in self: |
|
|
for role in self: |
|
@ -44,20 +43,17 @@ class ResUsersRole(models.Model): |
|
|
new_record.update_users() |
|
|
new_record.update_users() |
|
|
return new_record |
|
|
return new_record |
|
|
|
|
|
|
|
|
@api.multi |
|
|
|
|
|
def write(self, vals): |
|
|
def write(self, vals): |
|
|
res = super(ResUsersRole, self).write(vals) |
|
|
res = super(ResUsersRole, self).write(vals) |
|
|
self.update_users() |
|
|
self.update_users() |
|
|
return res |
|
|
return res |
|
|
|
|
|
|
|
|
@api.multi |
|
|
|
|
|
def unlink(self): |
|
|
def unlink(self): |
|
|
users = self.mapped('user_ids') |
|
|
users = self.mapped('user_ids') |
|
|
res = super(ResUsersRole, self).unlink() |
|
|
res = super(ResUsersRole, self).unlink() |
|
|
users.set_groups_from_roles(force=True) |
|
|
users.set_groups_from_roles(force=True) |
|
|
return res |
|
|
return res |
|
|
|
|
|
|
|
|
@api.multi |
|
|
|
|
|
def update_users(self): |
|
|
def update_users(self): |
|
|
"""Update all the users concerned by the roles identified by `ids`.""" |
|
|
"""Update all the users concerned by the roles identified by `ids`.""" |
|
|
users = self.mapped('user_ids') |
|
|
users = self.mapped('user_ids') |
|
@ -87,7 +83,6 @@ class ResUsersRoleLine(models.Model): |
|
|
'res.company', 'Company', |
|
|
'res.company', 'Company', |
|
|
default=lambda self: self.env.user.company_id) |
|
|
default=lambda self: self.env.user.company_id) |
|
|
|
|
|
|
|
|
@api.multi |
|
|
|
|
|
@api.constrains('user_id', 'company_id') |
|
|
@api.constrains('user_id', 'company_id') |
|
|
def _check_company(self): |
|
|
def _check_company(self): |
|
|
for record in self: |
|
|
for record in self: |
|
@ -98,7 +93,6 @@ class ResUsersRoleLine(models.Model): |
|
|
_('User "{}" does not have access to the company "{}"') |
|
|
_('User "{}" does not have access to the company "{}"') |
|
|
.format(record.user_id.name, record.company_id.name)) |
|
|
.format(record.user_id.name, record.company_id.name)) |
|
|
|
|
|
|
|
|
@api.multi |
|
|
|
|
|
@api.depends('date_from', 'date_to') |
|
|
@api.depends('date_from', 'date_to') |
|
|
def _compute_is_enabled(self): |
|
|
def _compute_is_enabled(self): |
|
|
today = datetime.date.today() |
|
|
today = datetime.date.today() |
|
@ -113,7 +107,6 @@ class ResUsersRoleLine(models.Model): |
|
|
if today > date_to: |
|
|
if today > date_to: |
|
|
role_line.is_enabled = False |
|
|
role_line.is_enabled = False |
|
|
|
|
|
|
|
|
@api.multi |
|
|
|
|
|
def unlink(self): |
|
|
def unlink(self): |
|
|
users = self.mapped('user_id') |
|
|
users = self.mapped('user_id') |
|
|
res = super(ResUsersRoleLine, self).unlink() |
|
|
res = super(ResUsersRoleLine, self).unlink() |
|
|