[FIX] mail & project: Display access button on mail notifications

This commit fixes two issues:

	- If a partner has multiple users and if any of these users is a
          share user, then the access button on mail notifications is not displayed.

	- If a project.task is either assigned or has its stage folded
	  the access button may not be displayed for certain users.
	  The users affected by this bug are the one who have their user's
	  partner is linked to multiple users with at least one flagged as a share user.
This commit is contained in:
Toufik Benjaa
2018-08-21 11:58:50 +02:00
parent 634de21b76
commit a05ae78abd
2 changed files with 11 additions and 6 deletions
+1 -1
View File
@@ -689,7 +689,7 @@ class MailThread(models.AbstractModel):
view_title = _('View')
default_groups = [
('user', lambda partner: bool(partner.user_ids) and not any(user.share for user in partner.user_ids), {}),
('user', lambda partner: bool(partner.user_ids) and any(not user.share for user in partner.user_ids), {}),
('portal', lambda partner: bool(partner.user_ids) and all(user.share for user in partner.user_ids), {
'has_button_access': False,
}),
+10 -5
View File
@@ -858,14 +858,19 @@ class Task(models.Model):
groups = super(Task, self)._notify_get_groups(message, groups)
self.ensure_one()
new_group = (
'group_project_user',
lambda partner: bool(partner.user_ids) and any(user.has_group('project.group_project_user') for user in partner.user_ids),
{},
)
if not self.user_id and not self.stage_id.fold:
take_action = self._notify_get_action_link('assign')
project_actions = [{'url': take_action, 'title': _('I take it')}]
new_group = (
'group_project_user', lambda partner: bool(partner.user_ids) and any(user.has_group('project.group_project_user') for user in partner.user_ids), {
'actions': project_actions,
})
groups = [new_group] + groups
new_group[2]['actions'] = project_actions
groups = [new_group] + groups
for group_name, group_method, group_data in groups:
if group_name == 'customer':