From 4c610a31b9d348b802eec6e567a62854c6263597 Mon Sep 17 00:00:00 2001 From: Tony Date: Wed, 1 Oct 2014 08:39:36 +0800 Subject: [PATCH] [FIX] survey: allow change of previous answers for all questions types Permission error on survey update The user who answer the survey may not have delete permission for the user_input_line In a survey, for a survey user (!= manager), When browsing previous pages of anwsers, the user wasn't allowed to change his answers regarding simple choice, multiple choices and matrix questions, as this kind of answers changes leaded to an unlink operation, not allowed for survey users. Closes #2901 --- addons/survey/survey.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/survey/survey.py b/addons/survey/survey.py index 21f2902e8be..aae53c6a750 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -21,6 +21,7 @@ from openerp.osv import fields, osv from openerp.tools.translate import _ +from openerp import SUPERUSER_ID from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT as DF from openerp.addons.website.models.website import slug from urlparse import urljoin @@ -1145,7 +1146,7 @@ class survey_user_input_line(osv.Model): ('question_id', '=', question.id)], context=context) if old_uil: - self.unlink(cr, uid, old_uil, context=context) + self.unlink(cr, SUPERUSER_ID, old_uil, context=context) if answer_tag in post and post[answer_tag].strip() != '': vals.update({'answer_type': 'suggestion', 'value_suggested': post[answer_tag]}) @@ -1176,7 +1177,7 @@ class survey_user_input_line(osv.Model): ('question_id', '=', question.id)], context=context) if old_uil: - self.unlink(cr, uid, old_uil, context=context) + self.unlink(cr, SUPERUSER_ID, old_uil, context=context) ca = dict_keys_startswith(post, answer_tag) comment_answer = ca.pop(("%s_%s" % (answer_tag, 'comment')), '').strip() @@ -1207,7 +1208,7 @@ class survey_user_input_line(osv.Model): ('question_id', '=', question.id)], context=context) if old_uil: - self.unlink(cr, uid, old_uil, context=context) + self.unlink(cr, SUPERUSER_ID, old_uil, context=context) no_answers = True ca = dict_keys_startswith(post, answer_tag)