Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.
Module: Sales Teams
Entity: crm.team
Compute Method: _compute_member_warning
| Inputs | Method | Outputs |
|---|---|---|
|
""" Display a warning message to warn user they are about to archive
other memberships. Only valid in mono-membership mode and take into
account only active memberships as we may keep several archived
memberships. """
self.member_warning = False
if all(team.is_membership_multi for team in self):
return
for team in self:
member_warning = False
other_memberships = self.env['crm.team.member'].search([
- ('crm_team_id', '!=', team.id if team.ids else False), # handle NewID
+ ('crm_team_id', '!=', team._origin.id if team.ids else False),
('user_id', 'in', team.member_ids.ids)
])
- if other_memberships and len(other_memberships) == 1:
- member_warning = _("Adding %(user_name)s in this team would remove him/her from its current team %(team_name)s.",
- user_name=other_memberships.user_id.name,
- team_name=other_memberships.crm_team_id.name
- )
- elif other_memberships:
- member_warning = _("Adding %(user_names)s in this team would remove them from their current teams (%(team_names)s).",
+ if other_memberships:
+ member_warning = _("Adding %(user_names)s in this team will remove them from %(team_names)s.",
user_names=", ".join(other_memberships.mapped('user_id.name')),
team_names=", ".join(other_memberships.mapped('crm_team_id.name'))
)
if member_warning:
- team.member_warning = member_warning + " " + _("To add a Salesperson into multiple Teams, activate the Multi-Team option in settings.")
+ team.member_warning = member_warning + " " + _("Working in multiple teams? Activate the option under Configuration>Settings.")
|
|
