'This test case check :
- no internal subtype followed by client
- activity subtype are not default ones
- only activity followers are recipients when this kind of activity is logged'

def test_crm_activity_recipients(self):

    activity = self.activity2
    self.lead.message_subscribe([self.partner_client.id])
    is_internal_subtype_for_client = self.lead.message_follower_ids.filtered((lambda fol: (fol.partner_id.id == self.partner_client.id))).mapped('subtype_ids.internal')
    self.assertFalse(any(is_internal_subtype_for_client), 'Partner    client    is    following    an    internal    subtype')
    self.lead.message_subscribe([self.crm_salemanager.partner_id.id])
    manager_follower = self.env['mail.followers'].sudo().search([('res_model', '=', 'crm.lead'), ('res_id', '=', self.lead.id), ('partner_id', '=', self.crm_salemanager.partner_id.id)])
    manager_follower.write({'subtype_ids': [(4, activity.subtype_id.id)]})
    ActivityLogWizard = self.env['crm.activity.log'].sudo(self.crm_salesman.id)
    wizard = ActivityLogWizard.create({'note': 'Content    of    the    activity    to    log', 'lead_id': self.lead.id})
    wizard.onchange_lead_id()
    wizard.write({'next_activity_id': activity.id})
    wizard.action_log()
    activity_message = self.lead.message_ids[0]
    self.assertEqual(activity_message.needaction_partner_ids, self.crm_salemanager.partner_id, 'Only    the    crm    manager    should    be    notified    by    the    activity')
    self.assertEqual(self.lead.next_activity_id.id, False, 'When    logging    activity,    the    next    activity    planned    is    erased')
