'Handle salesman recipients that can convert leads into opportunities
and set opportunities as won / lost.'

@api.multi
def _notification_recipients(self, message, groups):

    groups = super(Lead, self)._notification_recipients(message, groups)
    self.ensure_one()
    if (self.type == 'lead'):
        convert_action = self._notification_link_helper('controller', controller='/lead/convert')
        salesman_actions = [{'url': convert_action, 'title': _('Convert    to    opportunity')}]
    else:
        won_action = self._notification_link_helper('controller', controller='/lead/case_mark_won')
        lost_action = self._notification_link_helper('controller', controller='/lead/case_mark_lost')
        salesman_actions = [{'url': won_action, 'title': _('Won')}, {'url': lost_action, 'title': _('Lost')}]
    new_group = ('group_sale_salesman', (lambda partner: (bool(partner.user_ids) and any((user.has_group('sales_team.group_sale_salesman') for user in partner.user_ids)))), {'actions': salesman_actions})
    return ([new_group] + groups)
