Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Surveys

Entity: survey.survey

Compute Method: _compute_session_question_answer_count

Inputs Method Outputs
""" We have to loop since our result is dependent of the survey.session_question_id and
        the survey.session_start_time.
        This field is currently used to display the count about a single survey, in the
        context of sessions, so it should not matter too much. """
for survey in self:
            [answer_count] = self.env['survey.user_input.line']._read_group(
                [('question_id', '=', survey.session_question_id.id),
                 ('survey_id', '=', survey.id),
                 ('create_date', '>=', survey.session_start_time)],
                aggregates=['user_input_id:count_distinct'],
            )[0]
            survey.session_question_answer_count = answer_count

Back to entity