- [IMP] Category becomes res_model

- [IMP] Correct display of simple_ and multiple_choice

- [IMP] Admin and display of matrices

- [REF] Some code cleaning

bzr revid: rim@openerp.com-20131126125303-ff1zhgbko30nvlxx
This commit is contained in:
Richard Mathot (OpenERP)
2013-11-26 13:53:03 +01:00
parent 51bb7204cd
commit ff01a81817
8 changed files with 258 additions and 253 deletions
+2 -1
View File
@@ -41,7 +41,7 @@ sent mails with user name and password for the invitation of the survey.
'survey_cron.xml',
'security/survey_security.xml',
'security/ir.model.access.csv',
'survey_view.xml',
'views/survey_views.xml',
'views/survey_templates.xml',
#'wizard/survey_answer.xml',
#'wizard/survey_print_statistics.xml',
@@ -62,4 +62,5 @@ sent mails with user name and password for the invitation of the survey.
'css': ['static/src/css/survey.css'],
'js': ['static/src/js/survey.js'],
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+23 -13
View File
@@ -49,7 +49,6 @@ class WebsiteSurvey(http.Controller):
surveys = survey_obj.browse(cr, uid, survey_ids, context=context)
return request.website.render('survey.list', {'surveys': surveys})
# Survey displaying
@website.route(['/survey/fill/<model("survey.survey"):survey>/<string:token>'],
type='http', auth='public', multilang=True)
@@ -127,10 +126,6 @@ class WebsiteSurvey(http.Controller):
# @website.route(['/survey/validate/<model("survey.survey"):survey>'],
# type='json', auth='public', multilang=True)
# def validate(self, survey=None, **post):
# # for each {K:V} in post, check
# _logger.debug("Incoming json data: " + post.__str__())
# return {'valid': True, 'errors': None}
@website.route(['/survey/submit/<model("survey.survey"):survey>'],
type='http', auth='public', multilang=True)
@@ -167,10 +162,8 @@ class WebsiteSurvey(http.Controller):
type='http', auth='public', multilang=True)
def print_empty_survey(self, survey=None, **post):
'''Display an empty survey in printable view'''
pagination = {'current': -1, 'next': 0}
return request.website.render('survey.survey_print',
{'survey': survey,
'pagination': pagination})
{'survey': survey, 'page_nr': 0})
# Pagination
@@ -289,11 +282,28 @@ class WebsiteSurvey(http.Controller):
# TODO when datepicker will be available
return errors
# def validate_simple_choice(self, question, post, answer_tag):
# problems = []
# if question.constr_mandatory:
# problems = problems + self.__has_empty_input(question, post, answer_tag)
# return problems
def validate_simple_choice(self, question, post, answer_tag):
errors = {}
comment_tag = "%s_%s" % (answer_tag, question.comment_children_ids[0].id)
# Empty answer to mandatory question
if question.constr_mandatory and not answer_tag in post:
errors.update({answer_tag: question.constr_error_msg})
# Answer is a comment and is empty
if question.constr_mandatory and answer_tag in post and post[answer_tag] == "-1" and question.comment_count_as_answer and comment_tag in post and not post[comment_tag].strip():
errors.update({answer_tag: question.constr_error_msg})
# There is a comment and it should be validated
# if question.comment_allowed and comment_tag in post and post[comment_tag].strip():
### if comments_allowed:
### if validation des comments required
###
### if comment_count_as answer and question mandatory
###
### else:
### if question mandatory:
return errors
# def validate_multiple_choice(self, question, post, answer_tag):
# problems = []
View File
+2
View File
@@ -17,9 +17,11 @@ $(document).ready(function () {
$('.js_drop select').change(function(){
var other_val = $(this).find('.js_other_option').val();
if($(this).val() === other_val){
$(this).parent().removeClass('col-md-12').addClass('col-md-6');
$(this).closest('.js_drop').find('input[data-oe-survey-othert="1"]').show().focus();
}
else{
$(this).parent().removeClass('col-md-6').addClass('col-md-12');
$(this).closest('.js_drop').find('input[data-oe-survey-othert="1"]').val("").hide();
}
});
+59 -13
View File
@@ -85,7 +85,7 @@ class survey_survey(osv.osv):
_columns = {
'title': fields.char('Title', size=128, required=1,
translate=True),
'category': fields.char('Category'),
'res_model': fields.char('Category'),
'page_ids': fields.one2many('survey.page', 'survey_id', 'Pages'),
'date_open': fields.datetime('Opening date'),
'date_close': fields.datetime('Closing date'),
@@ -121,7 +121,6 @@ class survey_survey(osv.osv):
}
_defaults = {
'category': lambda s, cr, uid, c: _('Uncategorized'),
'user_input_limit': 0,
'state': 'draft',
'visible_to_user': True,
@@ -360,25 +359,30 @@ class survey_question(osv.osv):
('simple_choice', 'Multiple choice (one answer)'),
('multiple_choice', 'Multiple choice (multiple answers)'),
('matrix', 'Matrix')], 'Question Type', required=1),
'matrix_subtype': fields.selection([('simple', 'One choice per line'),
('multiple', 'Several choices per line')], 'Matrix Type'),
'labels_ids': fields.one2many('survey.label',
'question_id', 'Suggested answers', oldname='answer_choice_ids'),
'labels_ids_2': fields.one2many('survey.label',
'question_id_2', 'Suggested answers'),
# Display options
'column_nb': fields.selection([('12', '1 column choices'),
('6', '2 columns choices'),
('4', '3 columns choices'),
('3', '4 columns choices'),
('2', '6 columns choices')
], 'Number of columns'),
('6', '2 columns choices'),
('4', '3 columns choices'),
('3', '4 columns choices'),
('2', '6 columns choices')],
'Number of columns'),
'display_mode': fields.selection([('columns', 'Columns'),
('dropdown', 'Dropdown menu')
], 'Display mode'),
('dropdown', 'Dropdown menu')],
'Display mode'),
# Comments
'comments_allowed': fields.boolean('Allow comments',
oldname="allow_comment"),
'comment_children_ids': fields.one2many('survey.question',
'parent_id', 'Comment question'), # one2one in fact
'comment_children_ids': fields.many2many('survey.question',
'question_comment_children_ids', 'comment_id', 'parent_id',
'Comment question'), # one2one in fact
'comment_count_as_answer': fields.boolean('Comment field is an answer choice',
oldname='make_comment_field'),
@@ -421,6 +425,7 @@ class survey_question(osv.osv):
_defaults = {
'page_id': lambda s, cr, uid, c: c.get('page_id'),
'type': 'free_text',
'matrix_subtype': 'simple',
'column_nb': '12',
'display_mode': 'dropdown',
'constr_type': 'at least',
@@ -559,8 +564,10 @@ class survey_label(osv.osv):
_columns = {
'question_id': fields.many2one('survey.question', 'Question',
required=True, ondelete='cascade'),
'sequence': fields.integer('Page number'),
ondelete='cascade'),
'question_id_2': fields.many2one('survey.question', 'Question',
ondelete='cascade'),
'sequence': fields.integer('Label Sequence order'),
'value': fields.char("Suggested value", translate=True,
required=True)
}
@@ -608,6 +615,45 @@ class survey_user_input(osv.osv):
('unique_token', 'UNIQUE (token)', 'A token must be unique!')
]
def create(self, cr, uid, vals, context=None):
#if not vals['test_entry']:
# if survey_obj.exists(cr, uid, survey.id, context=context) == []:
# return werkzeug.utils.redirect("/survey/")
# # In case of auth required, block public user
# if survey.auth_required and uid == request.registry['website'].get_public_user(request.cr, SUPERUSER_ID, request.context).id:
# return request.website.render("website.401")
# # In case of non open surveys
# if survey.state != 'open':
# return request.website.render("survey.notopen")
# # If enough surveys completed
# if survey.user_input_limit > 0:
# completed = user_input_obj.search(cr, uid, [('state', '=', 'done')], count=True)
# if completed >= survey.user_input_limit:
# return request.website.render("survey.notopen")
# # Manual surveying
# if not token:
# if survey.visible_to_user:
# user_input_id = user_input_obj.create(cr, uid, {'survey_id': survey.id})
# user_input = user_input_obj.browse(cr, uid, [user_input_id], context=context)[0]
# else: # An user cannot open hidden surveys without token
# return request.website.render("website.403")
# else:
# try:
# user_input_id = user_input_obj.search(cr, uid, [('token', '=', token)])[0]
# except IndexError: # Invalid token
# return request.website.render("website.403")
# else:
# user_input = user_input_obj.browse(cr, uid, [user_input_id], context=context)[0]
return super(survey_user_input, self).create(cr, uid, vals, context)
# raise osv.except_osv(_('Warning!'), _('You must enter one or more answers for question "%s" of page %s .') % (vals['question'], page.title))
def do_clean_emptys(self, cr, uid, automatic=False, context=None):
''' Remove empty user inputs that have been created manually '''
empty_user_input_ids = self.search(cr, uid,
+6 -7
View File
@@ -1,20 +1,19 @@
<?xml version="1.0"?>
<openerp>
<data noupdate="1">
<!-- Remove unused user inputs -->
<record forcecreate="True" id="ir_cron_clean_empty_surveys"
model="ir.cron">
<field name="name">Run Clean empty surveys</field>
<field eval="True" name="active" />
<field name="user_id" ref="base.user_root" />
<field name="active" eval="True"/>
<field name="user_id" ref="base.user_root"/>
<field name="interval_number">1</field>
<field name="interval_type">hours</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall" />
<field eval="'survey.user_input'" name="model" />
<field eval="'do_clean_emptys'" name="function" />
<field eval="'(False,)'" name="args" />
<field name="doall" eval="False"/>
<field name="model" eval="'survey.user_input'"/>
<field name="function" eval="'do_clean_emptys'"/>
<field name="args" eval="'()'"/>
</record>
</data>
</openerp>
+63 -73
View File
@@ -9,11 +9,10 @@
<h1>Open surveys</h1>
<div class="table-responsive">
<table class="table table-hover">
<tr><th>Title</th><th>Category</th></tr>
<tr><th>Title</th></tr>
<t t-foreach="surveys" t-as="survey">
<tr>
<td><a t-att-href="survey.public_url" t-field="survey.title" /></td>
<td><span t-field="survey.category"/></td>
</tr>
</t>
</table>
@@ -28,7 +27,7 @@
<t t-call="website.layout">
<div class="wrap">
<div class="container">
<div class="jumbotron">
<div class="jumbotron mt32">
<h1>Thank you!</h1>
<div t-field="survey.thank_you_message" />
</div>
@@ -42,7 +41,7 @@
<t t-call="website.layout">
<div class="wrap">
<div class="container">
<div class="jumbotron">
<div class="jumbotron mt32">
<h1>Not open</h1>
<p>This survey is not open. Thank you for your interest!</p>
</div>
@@ -89,9 +88,7 @@
<!-- A page -->
<template id="page" name="Page">
<div class="page-header">
<progress t-att-value="page_nr + 1" t-att-max="len(survey.page_ids)" class="pull-right">
Page <span t-raw='page_nr + 1'/> on <span t-raw="len(survey.page_ids)"/>
</progress>
<p class="pull-right">Page <span t-raw='page_nr + 1'/> on <span t-raw="len(survey.page_ids)"/></p>
<h1 t-field='page.title' />
<div t-field='page.description'/>
</div>
@@ -104,16 +101,16 @@
<div class="js_question-wrapper" t-att-id="prefix">
<h2>
<span t-field='question.question' />
<abbr t-if="question.constr_mandatory" title="This question is mandatory." class="text-danger">*</abbr>
<span t-if="question.constr_mandatory" class="text-danger">*</span>
</h2>
<p class="text-muted"><t t-if="question.description"><span t-field='question.description'/></t></p>
<t t-if="question.type in ['free_text']"><t t-call="survey.free_text"/></t>
<t t-if="question.type in ['textbox']"><t t-call="survey.textbox"/></t>
<t t-if="question.type in ['numerical_box']"><t t-call="survey.numerical_box"/></t>
<t t-if="question.type in ['datetime']"><t t-call="survey.datetime"/></t>
<t t-if="question.type in ['simple_choice']"><t t-call="survey.simple_choice"/></t>
<t t-if="question.type in ['multiple_choice']"><t t-call="survey.multiple_choice"/></t>
<t t-if="question.type in ['matrix']"><t t-call="survey.matrix"/></t>
<t t-if="question.type == 'free_text'"><t t-call="survey.free_text"/></t>
<t t-if="question.type == 'textbox'"><t t-call="survey.textbox"/></t>
<t t-if="question.type == 'numerical_box'"><t t-call="survey.numerical_box"/></t>
<t t-if="question.type == 'datetime'"><t t-call="survey.datetime"/></t>
<t t-if="question.type == 'simple_choice'"><t t-call="survey.simple_choice"/></t>
<t t-if="question.type == 'multiple_choice'"><t t-call="survey.multiple_choice"/></t>
<t t-if="question.type == 'matrix'"><t t-call="survey.matrix"/></t>
<div class="js_errzone alert alert-danger" style="display:none;"></div>
</div>
</t>
@@ -144,111 +141,104 @@
<template id="simple_choice" name="Simple choice">
<div t-if="question.display_mode == 'dropdown'" class="js_drop row">
<div class="col-md-6">
<div class="col-md-12">
<select class="form-control" t-att-name="prefix">
<option disabled="1" selected="1">Choose...</option>
<option disabled="1" selected="1" value="">Choose...</option>
<t t-foreach='question.labels_ids' t-as='label'>
<option><t t-esc='label.value'/></option>
<option t-att-value='label.id'><t t-esc='label.value'/></option>
</t>
<t t-if='question.comments_allowed and question.comment_count_as_answer'>
<option class="js_other_option"><span t-esc="question.children_ids[0].question" /></option>
<option class="js_other_option" value="-1"><span t-esc="question.comment_children_ids[0].question" /></option>
</t>
</select>
</div>
<div class="col-md-6">
<t t-if='question.comments_allowed and question.comment_count_as_answer'>
<input type="text" class="form-control" t-att-name="prefix+'_other'" data-oe-survey-othert="1"/>
</t>
<t t-if='question.comments_allowed and not question.comment_count_as_answer'>
<div>
<span t-field="question.children_ids[0].question" />
<input type="text" class="form-control" t-att-name="prefix+'_comments'"/>
</div>
</t>
<div t-if='question.comments_allowed and question.comment_count_as_answer' class="col-md-6">
<input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, question.comment_children_ids[0].id)" data-oe-survey-othert="1"/>
</div>
<div t-if='question.comments_allowed and not question.comment_count_as_answer' class="col-md-12 mt16">
<span t-field="question.comment_children_ids[0].question"/>
<input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, question.comment_children_ids[0].id)"/>
</div>
</div>
<div t-if="question.display_mode == 'columns' " class="row js_radio">
<div t-foreach='question.labels_ids' t-as='label' t-attf-class="col-md-#{question.column_nb}">
<label>
<input type="radio" t-att-name="prefix" t-att-value='label.value' />
<input type="radio" t-att-name="prefix" t-att-value='label.id' />
<span t-field='label.value'/>
</label>
</div>
<div t-if='question.comments_allowed and question.comment_count_as_answer' class="js_comments col-md-12" >
<label>
<input type="radio" t-att-name="prefix" />
<span t-field="question.children_ids[0].question" />
<input type="radio" t-att-name="prefix" value="-1"/>
<span t-field="question.comment_children_ids[0].question" />
</label>
<input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, question.children_ids[0].id)"/>
<input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, question.comment_children_ids[0].id)"/>
</div>
<div t-if='question.comments_allowed and not question.comment_count_as_answer' class="col-md-12">
<span t-field="question.children_ids[0].question"/>
<input type="text" class="form-control" t-att-name="prefix+'_comments'" data-oe-survey-othert="1"/>
<span t-field="question.comment_children_ids[0].question"/>
<input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, question.comment_children_ids[0].id)" data-oe-survey-othert="1"/>
</div>
</div>
</template>
<!--
<template id="simple_choice" name="Simple choice">
<t t-if="question.choices_display == 'dropdown'">
<div class="js_drop row">
<div class="col-md-6">
<select class="form-control" t-att-name="prefix">
<option disabled="1" selected="1">Choose...</option>
<t t-foreach='question.labels_ids' t-as='label'>
<option><t t-esc='label.value'/></option>
</t>
<t t-if='question.comments_allowed and question.comment_count_as_answer'>
<option class="js_other_option"><span t-esc="question.children_ids[0].question" /></option>
</t>
</select>
</div>
<div class="col-md-6">
<t t-if='question.comments_allowed and question.comment_count_as_answer'>
<input type="text" class="form-control" t-att-name="prefix+'_other'" data-oe-survey-othert="1"/>
</t>
<t t-if='question.comments_allowed and not question.comment_count_as_answer'>
<div>
<span t-field="question.children_ids[0].question" />
<input type="text" class="form-control" t-att-name="prefix+'_comments'"/>
</div>
</t>
</div>
</div>
</t>
</template> -->
<template id="multiple_choice" name="Multiple choice">
<div class="row">
<div t-foreach='question.labels_ids' t-as='label' t-attf-class="col-md-#{question.column_nb}">
<label>
<input type="checkbox" t-att-name="'%s_%s' % (prefix, label.id)" t-att-value='label.value' />
<input type="checkbox" t-att-name="'%s_%s' % (prefix, label.id)" t-att-value='label.id' />
<span t-field='label.value'/>
</label>
</div>
<div t-if='question.comments_allowed and question.comment_count_as_answer' class="js_ck_comments col-md-12" >
<label>
<input type="checkbox" t-att-name="prefix + '_other'" />
<span t-field="question.children_ids[0].question" />
<input type="checkbox" t-att-name="'%s_%s' % (prefix, -1)" value="-1" />
<span t-field="question.comment_children_ids[0].question" />
</label>
<input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, question.children_ids[0].id)"/>
<input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, question.comment_children_ids[0].id)"/>
</div>
<div t-if='question.comments_allowed and not question.comment_count_as_answer' class="col-md-12">
<span t-field="question.children_ids[0].question"/>
<input type="text" class="form-control" t-att-name="prefix+'_comments'" data-oe-survey-othert="1"/>
<span t-field="question.comment_children_ids[0].question"/>
<input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, question.comment_children_ids[0].id)" data-oe-survey-othert="1"/>
</div>
</div>
</template>
<template id="matrix" name="Matrix">
<table class="table table-hover">
<thead>
<tr>
<th> </th>
<th t-foreach="question.labels_ids" t-as="col_label"><span t-field="col_label.value" /></th>
</tr>
</thead>
<tbody>
<tr t-foreach="question.labels_ids_2" t-as="row_label">
<th><span t-field="row_label.value" /></th>
<td t-foreach="question.labels_ids" t-as="col_label">
<input t-if="question.matrix_subtype == 'simple'" type="radio" t-att-name="'%s_%s' % (prefix, row_label.id)" t-att-value='col_label.id' />
<input t-if="question.matrix_subtype == 'multiple'" type="checkbox" t-att-name="'%s_%s_%s' % (prefix, row_label.id, col_label.id)" t-att-value='col_label.id' />
</td>
</tr>
</tbody>
</table>
<div t-if='question.comments_allowed'>
<span t-field="question.comment_children_ids[0].question"/>
<input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, question.comment_children_ids[0].id)" />
</div>
</template>
<!-- Printable view of a survey (all pages) -->
<template id="survey_print" name="Survey">
<t t-call="website.layout">
<t t-set="head">
<script type="text/javascript" src="/survey/static/src/js/survey.js" />
</t>
<div class="wrap">
<div class="container">
<div class="row">
<div class='jumbotron'>
<div class='jumbotron mt32'>
<h1><span t-field='survey.title'/></h1>
<t t-if="survey.description is not False"><p><span t-field='survey.description'/></p></t>
<t t-if="survey.description is not False"><div t-field='survey.description'/></t>
</div>
<t t-foreach="survey.page_ids" t-as="page">
<t t-call="survey.page" />
@@ -257,7 +247,7 @@
</div>
</div>
</div>
</t>
</t>
</template>
</data>
</openerp>
@@ -104,39 +104,40 @@
</record>
<!--
Survey
-->
<!-- SURVEY -->
<record model="ir.ui.view" id="survey_form">
<field name="name">survey_form</field>
<field name="model">survey.survey</field>
<field name="priority">1</field>
<field name="arch" type="xml">
<form string="Survey" version="7.0">
<header groups="base.group_survey_manager">
<!-- <button name="action_edit_survey" states="draft" string="Edit Survey" type="object" class="oe_highlight"/>
<record model="ir.ui.view" id="survey_form">
<field name="name">survey_form</field>
<field name="model">survey.survey</field>
<field name="priority">1</field>
<field name="arch" type="xml">
<form string="Survey" version="7.0">
<header groups="base.group_survey_manager">
<button name="action_edit_survey" states="draft" string="Edit Survey" type="object" class="oe_highlight"/>
<button name="survey_cancel" string="Cancel" states="draft" type="object"/>
<button name="action_send_survey" string="Invite people" states="open" type="object" class="oe_highlight"/> -->
<button name="action_send_survey" string="Invite people" states="open" type="object" class="oe_highlight"/>
<field name="state" widget="statusbar" statusbar_visible="draft,open,close,cancelled" clickable="True"/>
</header>
<sheet class="oe_survey">
<notebook colspan="4">
<page string="Configuration">
<div class="oe_button_box oe_right" groups="base.group_survey_manager">
<button name="action_test_survey" string="Test Survey" type="object"/>
<button name="action_print_survey" string="Print Survey" type="object"/>
</div>
<div class="oe_title">
<label for="title" class="oe_edit_only"/>
<h1>
<field name="title" attrs="{'readonly':[('state','in',['close','cancel'])]}"/>
</h1>
</div>
<field name="description" attrs="{'readonly': True}"/>
</page>
<div class="oe_button_box oe_right" groups="base.group_survey_manager">
<button name="action_test_survey" string="Test Survey" type="object"/>
<button name="action_print_survey" string="Print Survey" type="object"/>
</div>
<div class="oe_title">
<label for="title" class="oe_edit_only"/>
<h1>
<field name="title" attrs="{'readonly':[('state','in',['close','cancel'])]}"/>
</h1>
</div>
<group nolabel="1" col="4">
<field name="visible_to_user" />
<field name="auth_required" />
<field name="public_url" widget="url" />
</group>
<field name="description" attrs="{'readonly': True}"/>
<notebook>
<page string="Pages and questions">
<field name="page_ids" colspan="4" mode="tree" attrs="{'readonly':[('state','=','close')]}" context="{'default_survey_id': active_id}" nolabel="1">
<field name="page_ids" mode="tree" attrs="{'readonly':[('state','=','close')]}" context="{'default_survey_id': active_id}" nolabel="1">
<tree>
<field name="sequence" widget="handle"/>
<field name="title"/>
@@ -145,18 +146,16 @@
</field>
</page>
<page string="Survey options">
<group nolabel="1" colspan="4">
<field name="category" attrs="{'readonly':[('state','in',['close','cancel'])]}"/>
<group nolabel="1" col="4">
<field name="user_input_limit" attrs="{'readonly':[('state','=','close')]}"/>
<field name="visible_to_user"/>
<field name="auth_required" />
<field name="users_can_go_back" />
<field name="public_url" widget="url"/>
<field name="thank_you_message" attrs="{'readonly': True}"/>
<label string="completed surveys" colspan="2"/>
<field name="users_can_go_back" colspan="4" />
<field name="thank_you_message" colspan="4" attrs="{'readonly': True}"/>
<field name="res_model" attrs="{'invisible': True}"/>
</group>
</page>
<page string="User inputs">
<field name="user_input_ids" colspan="4" mode="tree">
<field name="user_input_ids" mode="tree">
<tree>
<field name="date_create"/>
<field name="deadline"/>
@@ -186,7 +185,6 @@
<field name="arch" type="xml">
<tree colors="gray:state == 'close'" string="Survey">
<field name="title" />
<field name="category"/>
<field name="date_open" string="Opening date" />
<field name="date_close" string="Closing date" />
<field name="state" />
@@ -208,7 +206,6 @@
<field name="arch" type="xml">
<search string="Search Survey">
<field name="title" string="Survey"/>
<field name="category"/>
<filter string="Draft" domain="[('state','=', 'draft')]"/>
<filter string="Open" domain="[('state','=','open')]"/>
<filter string="Closed" domain="[('state','=','close')]"/>
@@ -216,7 +213,6 @@
<separator/>
<filter string="Not completed yet" name="unread_message" domain="['&amp;', ('response_ids.state', 'in', ['new', 'skip']), ('response_ids.partner_id.user_id', '=', uid)]"/>
<group expand="1" string="Group by...">
<filter string="Category" name="group_category" icon="terp-stock_symbol-selection" domain="[]" context="{'group_by':'category'}"/>
<filter string="Status" name="group_status" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
</group>
</search>
@@ -240,13 +236,11 @@
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_color_#{kanban_getcolor(record.color.raw_value)} oe_kanban_card oe_kanban_survey oe_kanban_global_click">
<span class="oe_survey_fill">
<t t-if="record.state.raw_value === 'open'"><a name="action_fill_survey" type="object">Fill in Survey</a></t>
<t t-if="record.state.raw_value !== 'open'"><a name="action_edit_survey" type="object">Test Survey</a></t>
</span>
<div class="oe_dropdown_toggle oe_dropdown_kanban" t-if="widget.view.is_action_enabled('edit')">
<span class="oe_e">i</span>
<ul class="oe_dropdown_menu">
<t t-if="widget.view.is_action_enabled('edit')"><li><a type="open">Survey Settings...</a></li></t>
<t t-if="widget.view.is_action_enabled('edit')"><li><a type="open">Edit...</a></li></t>
<t t-if="widget.view.is_action_enabled('delete')"><li><a type="delete">Delete</a></li></t>
<li><ul class="oe_kanban_colorpicker" data-field="color"/></li>
</ul>
@@ -263,8 +257,8 @@
<table class="oe_kanban_survey_list" t-if="widget.view.is_action_enabled('edit')">
<tr>
<td>
<t t-if="record.state.raw_value === 'open'"><a name="action_survey_fill2" type="object">Take survey</a></t>
<t t-if="record.state.raw_value !== 'open'"><span class="oe_inactive" title="You can only take open surveys">Take survey</span></t>
<t t-if="record.state.raw_value === 'open'"><a name="action_survey_fill2" type="object">Start survey</a></t>
<t t-if="record.state.raw_value !== 'open'"><span class="oe_inactive" title="You can only take open surveys">Start survey</span></t>
</td>
<td>
<t t-if="record.state.raw_value === 'open'"><a name="action_send_survey" type="object">Invite people</a></t>
@@ -300,20 +294,12 @@
<field name="view_mode">kanban,tree,form</field>
<field name="view_id" ref="view_survey_kanban"></field>
<field name="search_view_id" ref="survey_search"/>
<field name="context">{'search_default_group_category': 1}</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a new survey.
</p><p>
You can create survey for different purposes: recruitment
interviews, employee's periodical evaluations, marketing
campaigns, etc.
</p><p>
A survey is made of pages containing questions
of several types: text, multiple choices, etc.
</p>
</field>
</record>
<p class="oe_view_nocontent_create">Click to create a new survey.</p>
<p>You can create survey for different purposes: recruitment interviews, employee's periodical evaluations, marketing campaigns, etc.</p>
<p>A survey is made of pages containing questions of several types: text, multiple choices, etc.</p>
</field>
</record>
<!--
Survey Pages
@@ -333,7 +319,7 @@
<h1><field name="title"/></h1>
</div>
<field name="description" attrs="{'readonly': True}"/>
<group string="Questions">
<group nolabel="1">
<field name="question_ids" nolabel="1" mode="tree" context="{'default_page_id': active_id}">
<tree>
<field name="sequence" widget="handle"/>
@@ -412,22 +398,21 @@
<field name="arch" type="xml">
<form string="Survey Question" version="7.0">
<sheet class="oe_survey">
<group colspan="4" col="2">
<group col="4">
<!-- The question -->
<group colspan="2">
<group colspan="4">
<field name="type" readonly="context.get('is_comment_question', False)"/>
<field name="matrix_subtype" attrs="{'invisible':[('type','not in',['matrix'])]}"/>
<field name="question" />
<field name="description" />
</group>
<!-- Labels -->
<group colspan="2" string="Choice of answers" attrs="{'invisible':[('type','not in',['simple_choice', 'multiple_choice'])]}">
<field colspan="2" name="display_mode" string="Display mode" attrs="{'invisible':[('type','not in',['simple_choice'])]}"/>
<field colspan="2" name="column_nb" string="Number of columns" attrs="{'invisible':[('display_mode','=','dropdown'), ('type','=','simple_choice')]}"/>
<field colspan="2" name="labels_ids" nolabel="1" context="{'default_question_id': active_id}">
<tree string="Suggested answers" editable="bottom">
<group colspan="4" nolabel="1" attrs="{'invisible':[('type','not in',['simple_choice', 'multiple_choice'])]}">
<field name="display_mode" string="Display mode" attrs="{'invisible':[('type','not in',['simple_choice'])]}"/>
<field name="column_nb" string="Number of columns" attrs="{'invisible':[('display_mode','=','dropdown'), ('type','=','simple_choice')]}"/>
<field name="labels_ids" colspan="4" nolabel="1" context="{'default_question_id': active_id}">
<tree string="Answer choices" editable="bottom">
<field name="sequence" widget="handle"/>
<field name="value" />
</tree>
@@ -435,62 +420,68 @@
</group>
<!-- Sub-questions -->
<group colspan="2" attrs="{'invisible':[('type','not in',['matrix', 'vector'])]}">
<field name='children_ids' nolabel='1' context="{'default_parent_id': active_id}"/>
<group colspan="4" attrs="{'invisible':[('type','not in',['matrix'])]}">
<field name="labels_ids" colspan="4" nolabel="1" context="{'default_question_id': active_id}">
<tree editable="bottom">
<field name="sequence" widget="handle"/>
<field name="value" string="Columns labels"/>
</tree>
</field>
<field name="labels_ids_2" colspan="4" nolabel="1" context="{'default_question_id_2': active_id}">
<tree editable="bottom">
<field name="sequence" widget="handle"/>
<field name="value" string="Rows labels"/>
</tree>
</field>
</group>
<!-- Question validation -->
<group colspan="2" string="Question required" invisible="context.get('is_comment_question', False)">
<group colspan="4" nolabel="1" invisible="context.get('is_comment_question', False)">
<field name="constr_mandatory" string="Is this question mandatory?"/>
<group attrs="{'invisible':[('constr_mandatory','=',False)]}">
<group attrs="{'invisible':[('type','not in',['matrix'])]}">
<group colspan="4" attrs="{'invisible':[('constr_mandatory','=',False)]}">
<group colspan="4" col="4" attrs="{'invisible':[('type','not in',['matrix'])]}">
<field name="constr_type" string="Users must answer..."/>
<group attrs="{'invisible':[('constr_type','not in',['at least','a range'])]}">
<field name="constr_minimum_req_ans" nolabel="1" />
</group>
<group attrs="{'invisible':[('constr_type','not in',['at most','a range', 'exactly'])]}">
<field name="constr_maximum_req_ans" nolabel="1" />
</group>
<field name="constr_minimum_req_ans" nolabel="1" attrs="{'invisible':[('constr_type','not in',['at least','a range'])]}" />
<field name="constr_maximum_req_ans" nolabel="1" attrs="{'invisible':[('constr_type','not in',['at most','a range', 'exactly'])]}" />
</group>
<field name="constr_error_msg" string="Error message"/>
<field colspan="2" name="constr_error_msg" string="Error message"/>
</group>
</group>
<!-- Answer validation -->
<group colspan="1" string="Answer Validation" attrs="{'invisible':[('type','not in',['textbox'])]}">
<group colspan="4" col="4" nolabel="1" attrs="{'invisible':[('type','not in',['textbox'])]}">
<group>
<field name="validation_required"/>
<field name="validation_required" colspan="2"/>
<group colspan="2" attrs="{'invisible':[('validation_required','=',False)]}">
<group colspan="4" col="4" attrs="{'invisible':[('validation_required','=',False)]}">
<field name="validation_type" />
<group colspan="2" attrs="{'invisible':[('validation_type','!=','has_length')]}">
<field name="validation_error_msg" />
<group colspan="4" col="4" attrs="{'invisible':[('validation_type','!=','has_length')]}">
<field name="validation_length_min" string="between"/>
<field name="validation_length_max" string="and"/>
</group>
<group colspan="2" attrs="{'invisible':[('validation_type','!=','is_decimal')]}">
<group colspan="4" col="4" attrs="{'invisible':[('validation_type','!=','is_decimal')]}">
<field name="validation_min_float_value" string="between"/>
<field name="validation_max_float_value" string="and"/>
</group>
<group colspan="2" attrs="{'invisible':[('validation_type','!=','is_integer')]}">
<group colspan="4" col="4" attrs="{'invisible':[('validation_type','!=','is_integer')]}">
<field name="validation_min_int_value" string="between"/>
<field name="validation_max_int_value" string="and"/>
</group>
<group colspan="2" attrs="{'invisible':[('validation_type','!=','is_date')]}">
<group colspan="4" col="4" attrs="{'invisible':[('validation_type','!=','is_date')]}">
<field name="validation_min_date" string="between"/>
<field name="validation_max_date" string="and"/>
</group>
<field name="validation_error_msg" />
</group>
</group>
</group>
<!-- Comments -->
<group colspan="2" string="Comments" attrs="{'invisible':[('type','not in',['simple_choice','multiple_choice'])]}">
<group colspan="4" nolabel="1" attrs="{'invisible':[('type','not in',['simple_choice','multiple_choice', 'matrix'])]}">
<field name='comments_allowed' />
<group attrs="{'invisible':[('comments_allowed','=',False)]}">
<field name='comment_count_as_answer' />
<field colspan="2" nolabel="1" name="comment_children_ids" context="{'default_parent_id': active_id, 'default_type': 'textbox', 'is_comment_question': True}">
<group colspan="4" attrs="{'invisible':[('comments_allowed','=',False)]}">
<field name='comment_count_as_answer' attrs="{'invisible':[('type','not in',['simple_choice','multiple_choice'])]}" />
<field colspan="4" nolabel="1" name="comment_children_ids" context="{'default_parent_id': active_id, 'default_type': 'textbox', 'is_comment_question': True}" widget="many2man_tags">
<tree>
<field name="question" string="Comment question (only one question allowed, others will be ignored)"/>
</tree>
@@ -572,9 +563,9 @@
Survey Response Line
-->
<record model="ir.ui.view" id= "survey_response_line_form">
<!-- <record model="ir.ui.view" id= "survey_response_line_form">
<field name="name">survey_response_line_form</field>
<field name="model">survey.response.line</field>
<field name="model">survey.user_input_line</field>
<field name="arch" type="xml">
<form string="Survey Answer">
<field name="question_id"/>
@@ -600,7 +591,7 @@
<record model="ir.ui.view" id="survey_response_line_tree">
<field name="name">survey_response_line_tree</field>
<field name="model">survey.response.line</field>
<field name="model">survey.user_input_line</field>
<field name="arch" type="xml">
<tree string="Survey Answer Line">
<field name="page_id"/>
@@ -611,56 +602,26 @@
</field>
</record>
<!--
Survey Response Answer
-->
<record model="ir.actions.act_window" id="action_survey_user_input_form">
<field name="name">Survey User Input lines</field>
<field name="res_model">survey.user_input_line</field>
<field name="view_type">tree</field>
<field name="view_mode">tree</field>
<field name="context">{'default_group_by_question': True}</field>
</record> -->
<record model="ir.ui.view" id="survey_response_answer_tree">
<field name="name">survey_response_answer_tree</field>
<field name="model">survey.response.answer</field>
<field name="arch" type="xml">
<tree editable="top" string="Survey Answer">
<field name="answer_id"/>
<field name="answer" />
<field name="value_choice" />
<field name="column_id"/>
<field name="comment_field"/>
</tree>
</field>
</record>
<act_window
context="{'search_default_survey_id': [active_id], 'default_survey_id': active_id}"
id="act_survey_pages"
name="Pages"
res_model="survey.page"
src_model="survey.survey"/>
<!-- Actions -->
<act_window
context="{'search_default_survey': active_id, 'default_survey': active_id}"
id="act_survey_question"
name="Questions"
res_model="survey.question"
src_model="survey.survey"/>
<act_window context="{'search_default_survey_id': [active_id], 'default_survey_id': active_id}" id="act_survey_pages" name="Pages" res_model="survey.page" src_model="survey.survey"/>
<act_window
context="{'search_default_page_id': active_id, 'default_page_id': active_id}"
id="act_survey_page_question"
name="Questions"
res_model="survey.question"
src_model="survey.page"/>
<act_window context="{'search_default_survey': active_id, 'default_survey': active_id}" id="act_survey_question" name="Questions" res_model="survey.question" src_model="survey.survey"/>
<act_window domain="[('question_id', '=', active_id)]"
id="act_survey_answer"
name="Answers"
res_model="survey.label"
src_model="survey.question"/>
<act_window context="{'search_default_page_id': active_id, 'default_page_id': active_id}" id="act_survey_page_question" name="Questions" res_model="survey.question" src_model="survey.page"/>
<!--
<act_window domain="[('question_id', '=', active_id)]" id="act_survey_answer" name="Answers" res_model="survey.label" src_model="survey.question"/>
MENU ELEMENTS
-->
<!-- MENU ELEMENTS -->
<!-- Top menubar item -->
<menuitem name="Surveys" id="survey_main" sequence="120"/>
@@ -668,26 +629,22 @@
<!-- Left menu categories-->
<menuitem name="Surveys" id="menu_surveys" parent="survey_main" sequence="10" groups="base.group_survey_user"/>
<menuitem name="Statistics" id="menu_statistics" parent="survey_main" sequence="20" groups="base.group_survey_manager"/>
<menuitem name="Configuration" id="menu_surveys_configuration" parent="survey_main" sequence="30" groups="base.group_survey_manager"/>
<menuitem name="Advanced Configuration" id="menu_surveys_configuration" parent="survey_main" sequence="30" groups="base.group_no_one"/>
<!-- Left menu elements: Survey -->
<menuitem name="Surveys" id="menu_survey_form" action="action_survey_form" parent="menu_surveys" sequence="1"/>
<!-- Left menu elements: Statistics -->
<menuitem name="Surveys User inputs" id="menu_survey_type_form1" action="action_survey_user_input" parent="menu_statistics" sequence="1"/>
<menuitem name="Survey User inputs" id="menu_survey_type_form1" action="action_survey_user_input" parent="menu_statistics" sequence="1"/>
<!-- Left menu elements: Configuration -->
<!-- Left menu elements: Advanced Configuration -->
<menuitem name="Survey Pages" id="menu_survey_page_form1" action="action_survey_page_form" parent="menu_surveys_configuration" sequence="1"/>
<menuitem name="Survey Questions" id="menu_survey_question_form1" action="action_survey_question_form" parent="menu_surveys_configuration" sequence="2"/>
<menuitem name="Survey Labels" id="menu_survey_label_form1" action="action_survey_label_form" parent="menu_surveys_configuration" sequence="3"/>
<!-- web -->
<record id="action_survey_fill2" model="ir.actions.client">
<field name="res_model">survey.survey</field>
<field name="tag">survey.fill2</field>
</record>
<menuitem id="menu_survey_fill2" name="Survey Fill" parent="menu_surveys" action="action_survey_fill2"/>
<!-- <menuitem name="Survey User input lines" id="menu_survey_response_line_form" action="action_survey_user_input_form" parent="menu_surveys_configuration" sequence="4"/>
-->
</data>
</openerp>