From 080dfb3d1d7fb05acce47128f4f1ad966de45fa6 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Wed, 2 Dec 2020 14:37:39 +0000 Subject: [PATCH] [FIX] survey: no block on return to certification steps to reproduce: - start a certification with time limit - close it and go to it back after time limit +10 seconds is passed => an "There was an error during the validation of the survey." appear that prevent to finish the survey or do it a second time until the ongoing survey.user_input of the user is deleted. This was done to prevent people from cheating by answering after the time limit end. With this changeset, when we go back to the survey after its end, we will finish it without saving the answers. opw-2390623 closes #62752 closes odoo/odoo#62770 X-original-commit: 4d088ad719b456e73b7586087084a6d0b59ff455 Signed-off-by: Nicolas Lempereur (nle) Co-authored-by: David Beguin --- addons/survey/controllers/main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/survey/controllers/main.py b/addons/survey/controllers/main.py index fdb9753e983..fd577a3d01c 100644 --- a/addons/survey/controllers/main.py +++ b/addons/survey/controllers/main.py @@ -358,8 +358,12 @@ class Survey(http.Controller): if access_data['validity_code'] is not True: return self._redirect_with_error(access_data, access_data['validity_code']) + answer_sudo = access_data['answer_sudo'] + if answer_sudo.state != 'done' and answer_sudo.survey_time_limit_reached: + answer_sudo._mark_done() + return request.render('survey.survey_page_fill', - self._prepare_survey_data(access_data['survey_sudo'], access_data['answer_sudo'], **post)) + self._prepare_survey_data(access_data['survey_sudo'], answer_sudo, **post)) @http.route('/survey/get_background_image//', type='http', auth="public", website=True, sitemap=False) def survey_get_background(self, survey_token, answer_token):