[IMP] corrections on web client actions (all the links and buttons should work now)

[IMP] views enhancements
[REM] outdated code

bzr revid: rim@openerp.com-20140128124707-qlytna4nceoklw52
This commit is contained in:
Richard Mathot (OpenERP) 2014-01-28 13:47:07 +01:00
parent efd85595a5
commit 3e06758513
5 changed files with 226 additions and 146 deletions

View File

@ -58,7 +58,6 @@ sent mails with personal token for the invitation of the survey.
'sequence': 10,
'images': [],
'css': ['static/src/css/survey.css'],
'js': ['static/src/js/survey.js'],
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -35,11 +35,3 @@
.openerp .oe_kanban_survey .oe_inactive {
color: #aaaaaa;
}
.openerp .oe_kanban_survey .oe_stats_box {
width: 96px;
display: inline-block;
margin: 2px 2px 0px 0px;
text-align: center;
border: 1px solid rgba(0, 0, 0, 0.16);
}

View File

@ -1,20 +1,25 @@
/*
* OpenERP, Open Source Management Solution
* Copyright (C) 2004-TODAY OpenERP S.A. <http://www.openerp.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* OpenERP, Open Source Management Solution
* Copyright (C) 2004-TODAY OpenERP S.A. <http://www.openerp.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* This file is intended to add interactivity to survey forms rendered by
* the website engine.
*/
$(document).ready(function () {
'use strict';
@ -25,10 +30,12 @@ $(document).ready(function () {
var prefill_controller = the_form.attr("data-prefill");
var validate_controller = the_form.attr("data-validate");
var submit_controller = the_form.attr("data-submit");
var print_mode = false;
// Printing mode: will disable all the controls in the form
if (_.isUndefined(submit_controller)) {
$('.js_surveyform :input').prop('disabled', true);
print_mode = true
}
// Custom code for right behavior of radio buttons with comments box
@ -81,10 +88,6 @@ $(document).ready(function () {
return prefill_def;
};
// function validate(form){
// return false;
// }
// Parameters for form submission
$('.js_surveyform').ajaxForm({
url: submit_controller,
@ -115,14 +118,19 @@ $(document).ready(function () {
}
});
// Handles the event when a question is focused out
$('.js_question-wrapper').focusout(
function(){
console.debug("[survey] Focus lost on question " + $(this).attr("id"));
// // Handles the event when a question is focused out
// $('.js_question-wrapper').focusout(
// function(){
// console.debug("[survey] Focus lost on question " + $(this).attr("id"));
// });
// Launch prefilling
prefill().then(function(){
// Activate the print dialog if needed
if (print_mode){
window.print();
};
});
console.debug("[survey] Custom JS for survey loaded!");
// Launch prefilling
prefill();
});

View File

@ -90,13 +90,21 @@ class survey_survey(osv.Model):
def _get_public_url(self, cr, uid, ids, name, arg, context=None):
""" Computes a public URL for the survey """
res = dict((id, 0) for id in ids)
base_url = self.pool.get('ir.config_parameter').get_param(cr, uid,
'web.base.url')
for survey_browse in self.browse(cr, uid, ids, context=context):
res[survey_browse.id] = urljoin(base_url, "survey/start/%s/"
% survey_browse.id)
return res
return {id: urljoin(base_url, "survey/start/%s/" % id) for id in ids}
def _get_print_url(self, cr, uid, ids, name, arg, context=None):
""" Computes a printing URL for the survey """
base_url = self.pool.get('ir.config_parameter').get_param(cr, uid,
'web.base.url')
return {id: urljoin(base_url, "survey/print/%s/" % id) for id in ids}
def _get_result_url(self, cr, uid, ids, name, arg, context=None):
""" Computes an URL for the survey results """
base_url = self.pool.get('ir.config_parameter').get_param(cr, uid,
'web.base.url')
return {id: urljoin(base_url, "survey/result/%s/" % id) for id in ids}
# Model fields #
@ -104,8 +112,8 @@ class survey_survey(osv.Model):
'title': fields.char('Title', required=1, translate=True),
'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'),
'date_open': fields.datetime('Opening date', readonly=True),
'date_close': fields.datetime('Closing date', readonly=True),
'user_input_limit': fields.integer('Automatic closing limit',
help="Limits the number of instances of this survey that can be completed (if set to 0, no limit is applied)",
oldname='max_response_limit'),
@ -132,6 +140,10 @@ class survey_survey(osv.Model):
'User responses', readonly=1),
'public_url': fields.function(_get_public_url,
string="Public link", type="char"),
'print_url': fields.function(_get_print_url,
string="Print link", type="char"),
'result_url': fields.function(_get_result_url,
string="Results link", type="char"),
'email_template_id': fields.many2one('email.template',
'Email Template', ondelete='set null'),
'thank_you_message': fields.html('Thank you message', translate=True,
@ -153,6 +165,25 @@ class survey_survey(osv.Model):
# Public methods #
def write(self, cr, uid, ids, vals, context=None):
new_state = vals.get('state')
if new_state == 'draft':
vals.update({'date_open': None})
vals.update({'date_close': None})
self.message_post(cr, uid, ids, body="""<p>Survey drafted</p>""", context=context)
elif new_state == 'open':
if self._has_questions(cr, uid, ids, context=None):
vals.update({'date_open': fields.datetime.now(), 'date_close': None})
self.message_post(cr, uid, ids, body="""<p>Survey opened</p>""", context=context)
else:
raise osv.except_osv(_('Error!'), _('You can not open a survey that has no questions.'))
elif new_state == 'close':
vals.update({'date_close': fields.datetime.now()})
self.message_post(cr, uid, ids, body="""<p>Survey closed</p>""", context=context)
elif new_state == 'cancel':
self.message_post(cr, uid, ids, body="""<p>Survey cancelled</p>""", context=context)
return super(survey_survey, self).write(cr, uid, ids, vals, context=context)
def copy(self, cr, uid, ids, default=None, context=None):
vals = {}
current_rec = self.read(cr, uid, ids, context=context)
@ -201,35 +232,41 @@ class survey_survey(osv.Model):
else:
return (pages[current_page_index + 1][1], current_page_index + 1, False)
def action_edit_survey(self, cr, uid, ids, context=None):
''' Open a survey in edition view '''
id = ids[0]
context.update({
'survey_id': id,
'edit': True,
'ir_actions_act_window_target': 'new',
})
# Web client actions
def action_kanban_update_state(self, cr, uid, ids, context=None):
''' Change the state from the kanban ball '''
for survey in self.read(cr, uid, ids, ['state'], context=context):
if survey['state'] == 'draft':
self.write(cr, uid, [survey['id']], {'state': 'open'}, context=context)
elif survey['state'] == 'open':
self.write(cr, uid, [survey['id']], {'state': 'close'}, context=context)
elif survey['state'] == 'close':
self.write(cr, uid, [survey['id']], {'state': 'cancel'}, context=context)
elif survey['state'] == 'cancel':
self.write(cr, uid, [survey['id']], {'state': 'draft'}, context=context)
return {}
def action_start_survey(self, cr, uid, ids, context=None):
''' Open the website page with the survey form '''
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'survey.question.wiz',
'type': 'ir.actions.act_window',
'target': 'new',
'name': self.browse(cr, uid, id, context=context).title,
'context': context
'type': 'ir.actions.act_url',
'name': "Start Survey",
'target': 'self',
'url': self.read(cr, uid, ids, ['public_url'], context=context)[0]['public_url']
}
def action_send_survey(self, cr, uid, ids, context=None):
''' Open a window to compose an email, pre-filled with the survey
message '''
if not self._has_questions(cr, uid, ids, context=None):
raise osv.except_osv(_('Error!'), _('You can not send a survey that has no questions.'))
raise osv.except_osv(_('Error!'), _('You cannot send an invitation for a survey that has no questions.'))
survey_browse = self.pool.get('survey.survey').browse(cr, uid, ids,
context=context)[0]
if survey_browse.state != "open":
raise osv.except_osv(_('Warning!'),
_("You cannot send invitations since the survey is not open."))
_("You cannot send invitations unless the survey is open."))
assert len(ids) == 1, 'This option should only be used for a single \
survey at a time.'
@ -239,15 +276,14 @@ class survey_survey(osv.Model):
template_id = templates[1] if len(templates) > 0 else False
ctx = dict(context)
ctx.update({
'default_model': 'survey.survey',
'default_res_id': ids[0],
'default_survey_id': ids[0],
'default_use_template': bool(template_id),
'default_template_id': template_id,
'default_composition_mode': 'comment',
'survey_state': survey_browse.state
})
ctx.update({'default_model': 'survey.survey',
'default_res_id': ids[0],
'default_survey_id': ids[0],
'default_use_template': bool(template_id),
'default_template_id': template_id,
'default_composition_mode': 'comment',
'survey_state': survey_browse.state}
)
return {
'type': 'ir.actions.act_window',
'view_type': 'form',
@ -257,24 +293,32 @@ class survey_survey(osv.Model):
'context': ctx,
}
def write(self, cr, uid, ids, vals, context=None):
new_state = vals.get('state')
if new_state == 'draft':
vals.update({'date_open': None})
vals.update({'date_close': None})
self.message_post(cr, uid, ids, body="""<p>Survey drafted</p>""", context=context)
elif new_state == 'open':
if self._has_questions(cr, uid, ids, context=None):
vals.update({'date_open': fields.datetime.now(), 'date_close': None})
self.message_post(cr, uid, ids, body="""<p>Survey opened</p>""", context=context)
else:
raise osv.except_osv(_('Error!'), _('You can not open a survey that has no questions.'))
elif new_state == 'close':
vals.update({'date_close': fields.datetime.now()})
self.message_post(cr, uid, ids, body="""<p>Survey closed</p>""", context=context)
elif new_state == 'cancel':
self.message_post(cr, uid, ids, body="""<p>Survey cancelled</p>""", context=context)
return super(survey_survey, self).write(cr, uid, ids, vals, context=context)
def action_print_survey(self, cr, uid, ids, context=None):
''' Open the website page with the survey printable view '''
return {
'type': 'ir.actions.act_url',
'name': "Print Survey",
'target': 'self',
'url': self.read(cr, uid, ids, ['print_url'], context=context)[0]['print_url']
}
def action_result_survey(self, cr, uid, ids, context=None):
''' Open the website page with the survey results view '''
return {
'type': 'ir.actions.act_url',
'name': "Results of the Survey",
'target': 'self',
'url': self.read(cr, uid, ids, ['result_url'], context=context)[0]['result_url']
}
def action_test_survey(self, cr, uid, ids, context=None):
''' Open the website page with the survey form into test mode'''
return {
'type': 'ir.actions.act_url',
'name': "Results of the Survey",
'target': 'self',
'url': self.read(cr, uid, ids, ['public_url'], context=context)[0]['public_url'] + "phantom/"
}
class survey_page(osv.Model):
@ -679,6 +723,10 @@ class survey_user_input(osv.Model):
'user_input_line_ids': fields.one2many('survey.user_input_line',
'user_input_id', 'Answers'),
# URLs used to display the answers
'result_url': fields.related('survey_id', 'result_url', string="Public link to the survey results"),
'print_url': fields.related('survey_id', 'print_url', string="Public link to the empty survey"),
#'quizz_score': fields.function()
}
_defaults = {
@ -692,12 +740,12 @@ class survey_user_input(osv.Model):
('unique_token', 'UNIQUE (token)', 'A token must be unique!')
]
def do_clean_emptys(self, cr, uid, automatic=False, context=None):
''' Remove empty user inputs that have been created manually
def copy(self, cr, uid, id, default=None, context=None):
raise osv.except_osv(_('Warning!'), _('You cannot duplicate this \
element!'))
.. note:
This function does not remove
'''
def do_clean_emptys(self, cr, uid, automatic=False, context=None):
''' Remove empty user inputs that have been created manually (cronjob) '''
empty_user_input_ids = self.search(cr, uid, [('type', '=', 'manually'),
('state', '=', 'new'),
('date_create', '<', (datetime.datetime.now() - datetime.timedelta(hours=1)).strftime(DF))],
@ -706,6 +754,7 @@ class survey_user_input(osv.Model):
self.unlink(cr, uid, empty_user_input_ids, context=context)
def action_survey_resent(self, cr, uid, ids, context=None):
''' Sent again the invitation '''
record = self.browse(cr, uid, ids[0], context=context)
context = context or {}
context.update({
@ -714,12 +763,27 @@ class survey_user_input(osv.Model):
'default_multi_email': record.email or "",
'default_public': 'email_private',
})
return self.pool.get('survey.survey').action_survey_sent(cr, uid,
return self.pool.get('survey.survey').action_send_survey(cr, uid,
[record.survey_id.id], context=context)
def copy(self, cr, uid, id, default=None, context=None):
raise osv.except_osv(_('Warning!'), _('You cannot duplicate this \
element!'))
def action_view_answers(self, cr, uid, ids, context=None):
''' Open the website page with the survey form '''
user_input = self.read(cr, uid, ids, ['print_url', 'token'], context=context)[0]
return {
'type': 'ir.actions.act_url',
'name': "View Answers",
'target': 'self',
'url': '%s%s/' % (user_input['print_url'], user_input['token'])
}
def action_survey_results(self, cr, uid, ids, context=None):
''' Open the website page with the survey results '''
return {
'type': 'ir.actions.act_url',
'name': "Survey Results",
'target': 'self',
'url': self.read(cr, uid, ids, ['result_url'], context=context)[0]['result_url']
}
class survey_user_input_line(osv.Model):
@ -735,7 +799,7 @@ class survey_user_input_line(osv.Model):
relation='survey.page', string="Page"),
'survey_id': fields.related('user_input_id', 'survey_id',
type="many2one", relation="survey.survey",
string='Survey'),
string='Survey', store=True),
'date_create': fields.datetime('Create Date', required=1),
'skipped': fields.boolean('Skipped'),
'answer_type': fields.selection([('text', 'Text'),

View File

@ -11,14 +11,14 @@
<field name="survey_id"/>
<field name="email"/>
<field name="partner_id"/>
<filter string="Completed" domain="[('state','=', 'done')]"/>
<filter string="Partially completed" domain="[('state','=', 'skip')]"/>
<filter string="New" domain="[('state','=', 'new')]"/>
<filter string="Completed" domain="[('state', '=', 'done')]"/>
<filter string="Partially completed" domain="[('state', '=', 'skip')]"/>
<filter string="New" domain="[('state', '=', 'new')]"/>
<filter string="Test" domain="[('state','=', 'test')]"/>
<group expand="0" string="Group By...">
<filter name="group_by_survey" string="Survey" domain="[]" context="{'group_by':'survey_id'}"/>
<filter string="Email" domain="[]" context="{'group_by':'email'}"/>
<filter string="Partner" domain="[]" context="{'group_by':['partner_id']}"/>
<filter name="group_by_survey" string="Survey" domain="[]" context="{'group_by': 'survey_id'}"/>
<filter string="Email" domain="[]" context="{'group_by': 'email'}"/>
<filter string="Partner" domain="[]" context="{'group_by': ['partner_id']}"/>
</group>
</search>
</field>
@ -27,10 +27,11 @@
<field name="name">survey_user_input_form</field>
<field name="model">survey.user_input</field>
<field name="arch" type="xml">
<form string="Survey User inputs" version="7.0">
<form string="Survey User inputs" version="7.0" create="false">
<header>
<button name="action_survey_resent" states="new,skip" string="Sent Invitation Again" type="object" class="oe_highlight" icon="gtk-redo"/><br/>
<button name="action_print_response" states="done" string="View Answers" type="object" class="oe_highlight" icon="gtk-print"/>
<button name="action_survey_resent" string="Sent Invitation Again" type="object" class="oe_highlight" attrs="{'invisible': ['|', ('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"/>
</header>
<sheet>
@ -67,7 +68,7 @@
<field name="name">survey_user_input_tree</field>
<field name="model">survey.user_input</field>
<field name="arch" type="xml">
<tree string="Survey User inputs" version="7.0">
<tree string="Survey User inputs" version="7.0" create="false">
<field name="survey_id"/>
<field name="date_create"/>
<field name="deadline"/>
@ -75,8 +76,6 @@
<field name="email"/>
<field name="type"/>
<field name="state"/>
<button name="action_survey_resent" states="new,skip" string="Resent the invitation" type="object" icon="gtk-redo"/>
<button name="action_print_response" states="done,skip" string="Print Answers" type="object" icon="gtk-print"/>
</tree>
</field>
</record>
@ -112,14 +111,13 @@
<field name="arch" type="xml">
<form string="Survey" version="7.0">
<header groups="base.group_survey_manager">
<button name="action_test_survey" string="Test Survey" states="draft,open" type="object"/>
<button name="action_send_survey" string="Invite people" states="open" type="object" class="oe_highlight" />
<button name="action_print_survey" string="Print Survey" type="object"/>
<button name="action_result_survey" string="View results" states="open,close,cancel" type="object" class="oe_highlight"/>
<field name="state" widget="statusbar" statusbar_visible="draft,open,close,cancel" clickable="True"/>
</header>
<sheet class="oe_survey">
<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>
@ -180,16 +178,12 @@
<field name="arch" type="xml">
<tree colors="gray:state == 'close'" string="Survey">
<field name="title" />
<field name="state" />
<field name="date_open" string="Opening date" />
<field name="date_close" string="Closing date" />
<field name="state" />
<field name="tot_sent_survey" string="Invitations sent" />
<field name="tot_start_survey" string="Started" />
<field name="tot_comp_survey" string="Completed" />
<field name="user_input_limit" string="Max closing limit" />
<button name="action_fill_survey" states="open"
string="Fill in Survey" type="object" icon="gtk-execute" context="{'survey_id': active_id}" attrs="{'invisible':[('state','!=','open')]}" />
<button name="action_print_survey" string="Print Answer" type="object" icon="gtk-print" />
<button name="print_statistics" string="Print Statistics" states="open,close,cancel" type="object" icon="gtk-print" groups="base.group_survey_manager" />
</tree>
</field>
</record>
@ -230,24 +224,24 @@
<templates>
<div t-name="kanban-box" t-attf-class="oe_kanban_color_#{kanban_getcolor(record.color.raw_value)} oe_kanban_card oe_kanban_survey oe_kanban_global_click">
<div class="oe_dropdown_toggle oe_dropdown_kanban" t-if="widget.view.is_action_enabled('edit')">
<span class="oe_e">i</span>
<span class="oe_e">i</span> <!-- icon for dropdown menu -->
<ul class="oe_dropdown_menu">
<li t-if="widget.view.is_action_enabled('edit')"><a type="open">Edit...</a></li>
<li><a type="edit" >Edit...</a></li>
<li t-if="record.state.raw_value === 'open' &amp;&amp; record.visible_to_user.raw_value === true"><a name="action_start_survey" type="object">Start Survey...</a></li>
<li t-if="record.state.raw_value === 'open'"><a name="action_send_survey" type="object">Invite People...</a></li>
<li t-if="record.state.raw_value === 'open'"><a name="action_survey_fill2" type="object">Start Survey...</a></li>
<li><a name="action_print_survey" type="object">Print Survey...</a></li>
<li t-if="record.tot_comp_survey.raw_value"><a name="%(action_selected_survey_user_input)d" type="action">View Answers...(<field name="tot_comp_survey"/><t t-if="record.user_input_limit.raw_value > 0"> / <field name="user_input_limit"/></t>)</a></li>
<li t-if="record.tot_comp_survey.raw_value"><a name="print_statistics" type="object">Print Statistics...</a></li>
<li><a name="%(action_selected_survey_user_input)d" type="action">View Answers...</a></li>
<li t-if="record.tot_comp_survey.raw_value"><a name="action_result_survey" type="object">View Results...</a></li>
<li t-if="widget.view.is_action_enabled('delete')"><a type="delete">Delete!</a></li>
<li><ul class="oe_kanban_colorpicker" data-field="color"/></li>
</ul>
</div>
<div class="oe_kanban_content">
<span class="oe_kanban_right" t-if="widget.view.is_action_enabled('edit')">
<a t-if="record.state.raw_value === 'draft'" title="Draft" class="oe_kanban_status"> </a>
<a t-if="record.state.raw_value === 'open'" title="Open" class="oe_kanban_status_green"> </a>
<a t-if="record.state.raw_value === 'close'" title="Closed" class="oe_kanban_status_red"> </a>
<a t-if="record.state.raw_value === 'cancel'" title="Cancelled" class="oe_kanban_status_salmon"> </a>
<a t-if="record.state.raw_value === 'draft'" title="Draft" class="oe_kanban_status" name="action_kanban_update_state" type="object"> </a>
<a t-if="record.state.raw_value === 'open'" title="Open" class="oe_kanban_status_green" name="action_kanban_update_state" type="object"> </a>
<a t-if="record.state.raw_value === 'close'" title="Closed" class="oe_kanban_status_red" name="action_kanban_update_state" type="object"> </a>
<a t-if="record.state.raw_value === 'cancel'" title="Cancelled" class="oe_kanban_status_salmon" name="action_kanban_update_state" type="object"> </a>
</span>
<h3 class="oe_kanban_ellipsis"><t t-esc="record.title.raw_value.toString()"></t></h3>
<div t-if="record.visible_to_user.raw_value === false">
@ -270,7 +264,7 @@
</div>
<div>
<center><b>
<a t-if="record.visible_to_user.raw_value === true" t-att-href="record.public_url.raw_value"><t t-esc="record.public_url.raw_value"/></a>
<a t-if="record.visible_to_user.raw_value === true" name="action_start_survey" type="object"><t t-esc="record.public_url.raw_value"/></a>
<t t-if="record.visible_to_user.raw_value === false">Survey only on invitation</t>
</b></center>
</div>
@ -299,7 +293,7 @@
<field name="name">Surveys</field>
<field name="res_model">survey.survey</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,tree,form,calendar</field>
<field name="view_mode">kanban,tree,calendar,form</field>
<field name="search_view_id" ref="survey_search"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">Click to create a new survey.</p>
@ -307,13 +301,15 @@
<p>A survey is made of pages containing questions of several types: text, multiple choices, etc.</p>
</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"/>
<act_window context="{'search_default_survey_id': [active_id], 'default_survey_id': active_id}" id="act_survey_question" name="Questions" res_model="survey.question" src_model="survey.survey"/>
<!-- PAGES -->
<record model="ir.ui.view" id="survey_page_form">
<field name="name">survey_page_form</field>
<field name="model">survey.page</field>
<field name="arch" type="xml">
<form string="Survey Page" version="7.0">
<form string="Survey Page" version="7.0" create="false">
<sheet class="oe_survey">
<group invisible="context.get('edit')" attrs="{'invisible': [('survey_id','!=',None)]}">
<field name="survey_id"/>
@ -341,7 +337,7 @@
<field name="name">survey_page_tree</field>
<field name="model">survey.page</field>
<field name="arch" type="xml">
<tree string="Survey Page">
<tree string="Survey Page" create="false">
<field name="sequence" widget="handle"/>
<field name="title"/>
<field name="survey_id"/>
@ -371,6 +367,7 @@
<field name="view_id" ref="survey_page_tree"></field>
<field name="context">{'search_default_group_by_survey': True}</field>
</record>
<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"/>
<record model="ir.ui.view" id="survey_page_wizard_test1">
<field name="name">survey_page_wizard_test</field>
<field name="model">survey.page</field>
@ -393,7 +390,7 @@
<field name="name">survey_question_form</field>
<field name="model">survey.question</field>
<field name="arch" type="xml">
<form string="Survey Question" version="7.0">
<form string="Survey Question" version="7.0" create="false">
<sheet class="oe_survey">
<group col="4">
<!-- The question -->
@ -480,7 +477,7 @@
<field name="name">survey_question_tree</field>
<field name="model">survey.question</field>
<field name="arch" type="xml">
<tree string="Survey Question">
<tree string="Survey Question" create="false">
<field name="sequence" widget="handle"/>
<field name="question"/>
<field name="page_id"/>
@ -521,7 +518,7 @@
<field name="name">survey_label_tree</field>
<field name="model">survey.label</field>
<field name="arch" type="xml">
<tree string="Survey Label">
<tree string="Survey Label" create="false">
<field name="sequence" widget="handle"/>
<field name="question_id"/>
<field name="question_id_2"/>
@ -529,13 +526,24 @@
</tree>
</field>
</record>
<record id="survey_label_search" model="ir.ui.view">
<field name="name">survey_label_search</field>
<field name="model">survey.label</field>
<field name="arch" type="xml">
<search string="Search Label">
<field name="question_id" string="Question"/>
<filter name="group_by_question" string="Question" domain="[]" context="{'group_by':'question_id'}"/>
</search>
</field>
</record>
<record model="ir.actions.act_window" id="action_survey_label_form">
<field name="name">Survey Labels</field>
<field name="res_model">survey.label</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="survey_label_tree"></field>
<field name="search_view_id" ref="survey_label_search"/>
<field name="context">{'search_default_group_by_question': True}</field>
</record>
<!-- USER INPUT LINES
@ -544,7 +552,7 @@
<field name="name">survey_user_input_line_form</field>
<field name="model">survey.user_input_line</field>
<field name="arch" type="xml">
<form string="User input line details" version="7.0">
<form string="User input line details" version="7.0" create="false">
<sheet>
<group col="4">
<field name="question_id"/>
@ -568,7 +576,7 @@
<field name="name">survey_response_line_tree</field>
<field name="model">survey.user_input_line</field>
<field name="arch" type="xml">
<tree string="Survey Answer Line">
<tree string="Survey Answer Line" create="false">
<field name="survey_id"/>
<field name="user_input_id"/>
<field name="page_id"/>
@ -579,20 +587,29 @@
</tree>
</field>
</record>
<record id="survey_response_line_search" model="ir.ui.view">
<field name="name">survey_response_line_search</field>
<field name="model">survey.user_input_line</field>
<field name="arch" type="xml">
<search string="Search User input lines">
<field name="user_input_id"/>
<field name="survey_id"/>
<group expand="1" string="Group by...">
<filter name="group_by_survey" string="Survey" domain="[]" context="{'group_by':'survey_id'}"/>
<filter name="group_by_user_input" string="User Input" domain="[]" context="{'group_by':'user_input_id'}"/>
</group>
</search>
</field>
</record>
<record model="ir.actions.act_window" id="action_survey_user_input_line">
<field name="name">Survey User Input lines</field>
<field name="res_model">survey.user_input_line</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="survey_response_line_search"/>
<field name="context">{'search_default_group_by_survey': True, 'search_default_group_by_user_input': True}</field>
</record>
<!-- ACTIONS -->
<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_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_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 -->
<!-- Top menubar item -->
@ -600,7 +617,7 @@
<!-- 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="Results" id="menu_statistics" parent="survey_main" sequence="20" groups="base.group_survey_manager"/>
<menuitem name="Technical Settings" id="menu_surveys_configuration" parent="survey_main" sequence="30" groups="base.group_no_one"/>
<!-- Left menu elements: Survey -->