From 35a5db92c245bade093f4b5be299c45901b19b1e Mon Sep 17 00:00:00 2001 From: mreficent Date: Tue, 25 Sep 2018 15:51:04 +0000 Subject: [PATCH] [REF] survey: rename survey.user_input type field to input_type Purpose of this commit is to rename type column to something matching the the real business use of the field. That way it is easier to find and grep in the code. It also lessens potential conflicts with type build-in python function. It also lessens conflicts when using the field in JS as type is a build-in attribute. Renaming type column is a long-living issue. We choose to do it at the beginning of the v13 development to catch errors as soon as possible. This commit is linked to task ID 1896245. It is also a subpart of community PR #27599. --- addons/survey/controllers/main.py | 2 +- addons/survey/models/survey.py | 4 ++-- addons/survey/views/survey_views.xml | 10 +++++----- addons/survey/wizard/survey_email_compose_message.py | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/survey/controllers/main.py b/addons/survey/controllers/main.py index 613d47824df..efc0e889318 100644 --- a/addons/survey/controllers/main.py +++ b/addons/survey/controllers/main.py @@ -225,7 +225,7 @@ class Survey(http.Controller): user_input = request.env['survey.user_input'].sudo().search([('token', '=', post['token'])], limit=1) except KeyError: # Invalid token return request.render("survey.403", {'survey': survey}) - user_id = request.env.user.id if user_input.type != 'link' else SUPERUSER_ID + user_id = request.env.user.id if user_input.input_type != 'link' else SUPERUSER_ID for question in questions: answer_tag = "%s_%s_%s" % (survey.id, page_id, question.id) diff --git a/addons/survey/models/survey.py b/addons/survey/models/survey.py index f6ae9f98c8c..41fc884faa2 100644 --- a/addons/survey/models/survey.py +++ b/addons/survey/models/survey.py @@ -698,7 +698,7 @@ class SurveyUserInput(models.Model): survey_id = fields.Many2one('survey.survey', string='Survey', required=True, readonly=True, ondelete='restrict') date_create = fields.Datetime('Creation Date', default=fields.Datetime.now, required=True, readonly=True, copy=False) deadline = fields.Datetime('Deadline', help="Date by which the person can open the survey and submit answers", oldname="date_deadline") - type = fields.Selection([('manually', 'Manually'), ('link', 'Link')], string='Answer Type', default='manually', required=True, readonly=True, oldname="response_type") + input_type = fields.Selection([('manually', 'Manually'), ('link', 'Link')], string='Answer Type', default='manually', required=True, readonly=True, oldname="type") state = fields.Selection([ ('new', 'Not started yet'), ('skip', 'Partially completed'), @@ -736,7 +736,7 @@ class SurveyUserInput(models.Model): (used as a cronjob declared in data/survey_cron.xml) """ an_hour_ago = fields.Datetime.to_string(datetime.datetime.now() - datetime.timedelta(hours=1)) - self.search([('type', '=', 'manually'), ('state', '=', 'new'), + self.search([('input_type', '=', 'manually'), ('state', '=', 'new'), ('date_create', '<', an_hour_ago)]).unlink() @api.multi diff --git a/addons/survey/views/survey_views.xml b/addons/survey/views/survey_views.xml index 7a31b4784f0..e3e03fc96d8 100644 --- a/addons/survey/views/survey_views.xml +++ b/addons/survey/views/survey_views.xml @@ -30,7 +30,7 @@
-