Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting a Question Deletes Collected Answers #99

Open
jhouxatjvx opened this issue Oct 18, 2023 · 0 comments
Open

Deleting a Question Deletes Collected Answers #99

jhouxatjvx opened this issue Oct 18, 2023 · 0 comments
Labels

Comments

@jhouxatjvx
Copy link

jhouxatjvx commented Oct 18, 2023

Module

Surveys (on odoo 16.0)

Describe the bug

If you delete a question from a survey, then all participation (completed survey submission / user_input) answers to that question get deleted.

##Steps to Reproduce
Super easy to reproduce. Submit completion of any survey (collect at least one participation/user_input). Then go to the survey and delete a question. Then go view the Survey Participation Result, and you'll see the question and answer are gone.

Expected behavior
If I attempt to delete a question on a survey with linked participations, I should get a ForeignKey constraint violation error.

##How to fix
Navigate to surveys > models > survey_user_input.py > SurveyUserInputLine(models.Model) class > question_id
(Currently line 619)
The line for question_id property says:
question_id = fields.Many2one('survey.question', string='Question', ondelete='cascade', required=True)
This looks like a bug to me. "ondelete='cascade' means that a deletion to the question will delete all answers. This should be ondelete='restrict' so that the database refuses to delete a question that has user-submitted survey answers.

@jhouxatjvx jhouxatjvx added the bug label Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant