[FIX] mail_activity_team: archived users
- If a user is archived but there's an automatic activity, the team check wouldn't locate him. We have to ensure the context. - When the automatic activity gets a user with no team, we should set the team to a void one as well. TT30470
This commit is contained in:
parent
745feb6367
commit
98ac2d25a9
@ -63,10 +63,12 @@ class MailActivity(models.Model):
|
|||||||
# SUPERUSER is inactive and then even if you add it
|
# SUPERUSER is inactive and then even if you add it
|
||||||
# to member_ids it's not taken account
|
# to member_ids it's not taken account
|
||||||
# To not be blocked we must add it to constraint condition
|
# To not be blocked we must add it to constraint condition
|
||||||
|
# We must consider also users that could be archived but come from
|
||||||
|
# an automatic scheduled activity
|
||||||
for _activity in self.filtered(
|
for _activity in self.filtered(
|
||||||
lambda a: a.user_id.id != SUPERUSER_ID
|
lambda a: a.user_id.id != SUPERUSER_ID
|
||||||
and a.team_id
|
and a.team_id
|
||||||
and a.user_id
|
and a.user_id
|
||||||
and a.user_id not in a.team_id.member_ids
|
and a.user_id not in a.team_id.with_context(active_test=True).member_ids
|
||||||
):
|
):
|
||||||
raise ValidationError(_("The assigned user is not member of the team."))
|
raise ValidationError(_("The assigned user is not member of the team."))
|
||||||
|
@ -21,7 +21,7 @@ class MailActivityMixin(models.AbstractModel):
|
|||||||
.with_context(default_res_model=self._name,)
|
.with_context(default_res_model=self._name,)
|
||||||
._get_default_team_id(user_id=user_id)
|
._get_default_team_id(user_id=user_id)
|
||||||
)
|
)
|
||||||
if team:
|
# Even if it comes empty, we don't want to mismatch the user's team
|
||||||
act_values.update({"team_id": team.id})
|
act_values.update({"team_id": team.id})
|
||||||
return super().activity_schedule(
|
return super().activity_schedule(
|
||||||
act_type_xmlid=act_type_xmlid,
|
act_type_xmlid=act_type_xmlid,
|
||||||
|
Loading…
Reference in New Issue
Block a user