[IMP] survey: add a category on surveys to allow filtering them

Purpose of this commit is to add a category selection field on surveys. It
will allow to filter / select surveys according to their category and their
main use.

This commit is linked to task ID 1911586 and PR #28986.
This commit is contained in:
Thibault Delavallée
2019-01-14 15:22:18 +00:00
parent 27328ca33c
commit f15861c36d
2 changed files with 15 additions and 3 deletions
+4
View File
@@ -31,6 +31,10 @@ class Survey(models.Model):
stage_id = fields.Many2one('survey.stage', string="Stage", default=_default_stage,
ondelete="restrict", copy=False, group_expand='_read_group_stage_ids')
is_closed = fields.Boolean("Is closed", related='stage_id.closed', readonly=True)
category = fields.Selection([
('default', 'Generic Survey')], string='Category',
default='default', required=True,
help='Category is used to know in which context the survey is used. Various apps may define their own categories when they use survey like jobs recruitment or employee appraisal surveys.')
# content
page_ids = fields.One2many('survey.page', 'survey_id', string='Pages', copy=True)
user_input_ids = fields.One2many('survey.user_input', 'survey_id', string='User responses', readonly=True, groups='survey.group_survey_user')
+11 -3
View File
@@ -33,9 +33,14 @@
<h1><field name="title" placeholder="Survey Title"/></h1>
</div>
<group>
<field name="access_mode"/>
<field name="quizz_mode"/>
<field name="users_can_go_back"/>
<group>
<field name="access_mode"/>
<field name="users_can_go_back"/>
</group>
<group>
<field name="category" invisible="1"/>
<field name="quizz_mode"/>
</group>
</group>
<group string="Edit Pages and Questions">
<field name="page_ids" mode="tree" context="{'default_survey_id': active_id}" nolabel="1">
@@ -145,6 +150,9 @@
<filter string="Upcoming Activities" name="activities_upcoming_all"
domain="[('activity_ids.date_deadline', '&gt;', context_today().strftime('%Y-%m-%d'))
]"/>
<group expand="0" string="Group By">
<filter string="Category" name="groupby_category" context="{'group_by': 'category'}"/>
</group>
</search>
</field>
</record>