[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.
This commit is contained in:
mreficent
2018-10-19 09:13:12 +00:00
committed by Thibault Delavallée
parent b70ccc45bd
commit 35a5db92c2
4 changed files with 9 additions and 9 deletions
+1 -1
View File
@@ -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)
+2 -2
View File
@@ -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
+5 -5
View File
@@ -30,7 +30,7 @@
<field name="arch" type="xml">
<form string="Survey User inputs" create="false">
<header>
<button name="action_survey_resend" string="Send Invitation Again" type="object" class="oe_highlight" attrs="{'invisible': ['|', ('type','=','manually'), ('state', '=', 'done')]}"/>
<button name="action_survey_resend" string="Send Invitation Again" type="object" class="oe_highlight" attrs="{'invisible': ['|', ('input_type','=','manually'), ('state', '=', 'done')]}"/>
<button name="action_view_answers" states="done" string="Print These Answers" type="object" class="oe_highlight" />
<button name="action_survey_results" string="View Results" type="object" />
<field name="state" widget="statusbar"/>
@@ -41,7 +41,7 @@
<group>
<field name="survey_id"/>
<field name="date_create"/>
<field name="type"/>
<field name="input_type"/>
<field name="token" groups="base.group_no_one"/>
</group>
<group>
@@ -76,7 +76,7 @@
<field name="deadline"/>
<field name="partner_id"/>
<field name="email"/>
<field name="type"/>
<field name="input_type"/>
<field name="state"/>
<field name="test_entry" invisible="True"/>
<field name="quizz_score" groups="base.group_no_one"/>
@@ -93,7 +93,7 @@
<field name="date_create"/>
<field name="partner_id"/>
<field name="email"/>
<field name="type"/>
<field name="input_type"/>
<field name="state"/>
<templates>
<t t-name="kanban-box">
@@ -102,7 +102,7 @@
<div class="o_kanban_record_headings">
<strong class="o_kanban_record_title"><t t-esc="record.survey_id.value"/></strong>
</div>
<span class="badge badge-pill"><t t-esc="record.type.value"/></span>
<span class="badge badge-pill"><t t-esc="record.input_type.value"/></span>
</div>
<div class="o_kanban_record_bottom">
<div class="oe_kanban_bottom_left">
@@ -150,7 +150,7 @@ class SurveyMailComposeMessage(models.TransientModel):
'survey_id': wizard.survey_id.id,
'deadline': wizard.date_deadline,
'date_create': fields.Datetime.now(),
'type': 'link',
'input_type': 'link',
'state': 'new',
'token': token,
'partner_id': partner_id,