'Handle auto subscription. Two methods for auto subscription exist:
- tracked res.users relational fields, such as user_id fields. Those fields
must be relation fields toward a res.users record, and must have the
track_visilibity attribute set.
- using subtypes parent relationship: check if the current model being
modified has an header record (such as a project for tasks) whose followers
can be added as followers of the current records. Example of structure
with project and task:
- st_project_1.parent_id = st_task_1
- st_project_1.res_model = \'project.project\'
- st_project_1.relation_field = \'project_id\'
- st_task_1.model = \'project.task\'
:param list updated_fields: list of updated fields to track
:param dict values: updated values; if None, the first record will be browsed
to get the values. Added after releasing 7.0, therefore
not merged with updated_fields argumment.'

@api.multi
def message_auto_subscribe(self, updated_fields, values=None):

    (new_partners, new_channels) = (dict(), dict())
    user_field_lst = self._message_get_auto_subscribe_fields(updated_fields)
    subtypes = self.env['mail.message.subtype'].search(['|', ('res_model', '=', False), ('parent_id.res_model', '=', self._name)])
    relation_fields = set([subtype.relation_field for subtype in subtypes if (subtype.relation_field is not False)])
    if ((not any(((relation in updated_fields) for relation in relation_fields))) and (not user_field_lst)):
        return True
    if (values is None):
        record = self[0]
        for updated_field in updated_fields:
            field_value = getattr(record, updated_field)
            if isinstance(field_value, models.BaseModel):
                field_value = field_value.id
            values[updated_field] = field_value
    headers = set()
    for subtype in subtypes:
        if (subtype.relation_field and values.get(subtype.relation_field)):
            headers.add((subtype.res_model, values.get(subtype.relation_field)))
    if headers:
        header_domain = (['|'] * (len(headers) - 1))
        for header in headers:
            header_domain += ['&', ('res_model', '=', header[0]), ('res_id', '=', header[1])]
        for header_follower in self.env['mail.followers'].sudo().search(header_domain):
            for subtype in header_follower.subtype_ids:
                if (subtype.parent_id and (subtype.parent_id.res_model == self._name)):
                    new_subtype = subtype.parent_id
                elif (subtype.res_model is False):
                    new_subtype = subtype
                else:
                    continue
                if header_follower.partner_id:
                    new_partners.setdefault(header_follower.partner_id.id, set()).add(new_subtype.id)
                else:
                    new_channels.setdefault(header_follower.channel_id.id, set()).add(new_subtype.id)
    user_ids = [values[name] for name in user_field_lst if values.get(name)]
    user_pids = [user.partner_id.id for user in self.env['res.users'].sudo().browse(user_ids)]
    for partner_id in user_pids:
        new_partners.setdefault(partner_id, None)
    for (pid, subtypes) in new_partners.items():
        subtypes = (list(subtypes) if (subtypes is not None) else None)
        self.message_subscribe(partner_ids=[pid], subtype_ids=subtypes, force=(subtypes != None))
    for (cid, subtypes) in new_channels.items():
        subtypes = (list(subtypes) if (subtypes is not None) else None)
        self.message_subscribe(channel_ids=[cid], subtype_ids=subtypes, force=(subtypes != None))
    user_pids = [user_pid for user_pid in user_pids if (user_pid != self.env.user.partner_id.id)]
    self._message_auto_subscribe_notify(user_pids)
    return True
