[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
This commit is contained in:
Tony 2014-10-01 08:39:36 +08:00 committed by Denis Ledoux
parent 9fed748647
commit 4c610a31b9
1 changed files with 4 additions and 3 deletions

View File

@ -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)