'Post report about the progress of the goals
:param users: users that are concerned by the report. If False, will
send the report to every user concerned (goal users and
group that receive a copy). Only used for challenge with
a visibility mode set to \'personal\'.
:param subset_goals: goals to restrict the report'

def report_progress(self, users=(), subset_goals=False):

    challenge = self
    MailTemplates = self.env['mail.template']
    if (challenge.visibility_mode == 'ranking'):
        lines_boards = challenge._get_serialized_challenge_lines(restrict_goals=subset_goals)
        body_html = MailTemplates.with_context(challenge_lines=lines_boards).render_template(challenge.report_template_id.body_html, 'gamification.challenge', challenge.id)
        challenge.message_post(body=body_html, partner_ids=challenge.mapped('user_ids.partner_id.id'), subtype='mail.mt_comment')
        if challenge.report_message_group_id:
            challenge.report_message_group_id.message_post(body=body_html, subtype='mail.mt_comment')
    else:
        for user in (users or challenge.user_ids):
            lines = challenge._get_serialized_challenge_lines(user, restrict_goals=subset_goals)
            if (not lines):
                continue
            body_html = MailTemplates.sudo(user).with_context(challenge_lines=lines).render_template(challenge.report_template_id.body_html, 'gamification.challenge', challenge.id)
            self.env['gamification.challenge'].message_post(body=body_html, partner_ids=[(4, user.partner_id.id)], subtype='mail.mt_comment')
            if challenge.report_message_group_id:
                challenge.report_message_group_id.message_post(body=body_html, subtype='mail.mt_comment')
    return challenge.write({'last_report_date': fields.Date.today()})
