diff --git a/addons/survey/static/src/css/survey.css b/addons/survey/static/src/css/survey.css index b17110a4ac5..e2630d1a246 100644 --- a/addons/survey/static/src/css/survey.css +++ b/addons/survey/static/src/css/survey.css @@ -69,9 +69,18 @@ text-decoration: none !important; } -.openerp .oe_survey_answer label { - max-width: 260px; - white-space: normal !important; +.openerp .oe_form .oe_survey_answer .oe_form_sheet label { + max-width: 280px; + white-space: normal; font-weight: bold; padding-right: 8px; +} + +.openerp .oe_form .oe_survey_answer .oe_survey_matrix_of_choices_only_one_ans label, +.openerp .oe_form .oe_survey_answer .matrix_of_choices_only_multi_ans label { + min-width: 240px; +} +.openerp .oe_popup_form .oe_form_sheet.oe_survey, +.openerp .oe_popup_form .oe_form_sheetbg.oe_survey { + padding-top: 0; } \ No newline at end of file diff --git a/addons/survey/survey.py b/addons/survey/survey.py index 762e79a2b42..8d815321a3a 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -345,8 +345,8 @@ class survey_question(osv.osv): 'req_error_msg': fields.text('Error Message', translate=True), 'allow_comment': fields.boolean('Allow Comment Field'), 'sequence': fields.integer('Sequence'), - 'tot_resp': fields.function(_calc_response, string="Total Answer"), - 'survey': fields.related('page_id', 'survey_id', type='many2one', relation='survey', string='Survey'), + 'tot_resp': fields.function(_calc_response, type="integer", string="Total Answer"), + 'survey_id': fields.related('page_id', 'survey_id', type='many2one', relation='survey', string='Survey'), 'descriptive_text': fields.html('Descriptive Text', translate=True), 'column_heading_ids': fields.one2many('survey.question.column.heading', 'question_id', ' Column heading'), 'type': fields.selection([('multiple_choice_only_one_ans', 'Multiple Choice (Only One Answer)'), @@ -410,6 +410,7 @@ class survey_question(osv.osv): } _defaults = { 'sequence': 1, + 'page_id': lambda s, cr, uid, c: c.get('page_id'), 'type': lambda s, cr, uid, c: _('multiple_choice_multiple_ans'), 'req_error_msg': lambda s, cr, uid, c: _('This question requires an answer.'), 'required_type': 'at least', @@ -449,6 +450,12 @@ class survey_question(osv.osv): 'in_visible_answer_type': True}) return {'value': val} + def on_change_page_id(self, cr, uid, ids, page_id, context=None): + if page_id: + page = self.pool.get('survey.page').browse(cr, uid, page_id, context=context) + return {'survey_id': page.survey_id.id} + return {'value': {}} + def write(self, cr, uid, ids, vals, context=None): questions = self.read(cr, uid, ids, ['answer_choice_ids', 'type', 'required_type', \ 'req_ans', 'minimum_req_ans', 'maximum_req_ans', 'column_heading_ids', 'page_id', 'question']) @@ -511,14 +518,14 @@ class survey_question(osv.osv): return super(survey_question, self).write(cr, uid, ids, vals, context=context) def create(self, cr, uid, vals, context=None): - page = self.pool.get('survey.page').browse(cr, uid, 'page_id' in vals and vals['page_id'] or context['page_id'], context=context).title + page = self.pool.get('survey.page').browse(cr, uid, 'page_id' in vals and vals['page_id'] or context['page_id'], context=context) if 'answer_choice_ids' in vals and not len(vals.get('answer_choice_ids', [])) and \ vals.get('type') not in ['descriptive_text', 'single_textbox', 'comment', 'table']: - raise osv.except_osv(_('Warning!'), _('You must enter one or more answers for question "%s" of page %s .') % (vals['question'], page)) + raise osv.except_osv(_('Warning!'), _('You must enter one or more answers for question "%s" of page %s .') % (vals['question'], page.title)) if 'column_heading_ids' in vals and not len(vals.get('column_heading_ids', [])) and \ vals.get('type') in ['matrix_of_choices_only_one_ans', 'matrix_of_choices_only_multi_ans', 'rating_scale']: - raise osv.except_osv(_('Warning!'), _('You must enter one or more column headings for question "%s" of page %s.') % (vals['question'], page)) + raise osv.except_osv(_('Warning!'), _('You must enter one or more column headings for question "%s" of page %s.') % (vals['question'], page.title)) if 'is_require_answer' in vals and vals.get('type') in ['multiple_choice_multiple_ans', 'matrix_of_choices_only_one_ans', \ 'matrix_of_choices_only_multi_ans', 'rating_scale', 'multiple_textboxes', 'numerical_textboxes', 'date', 'date_and_time']: @@ -550,14 +557,6 @@ class survey_question(osv.osv): 'context': context } - def default_get(self, cr, uid, fields, context=None): - if context is None: - context = {} - data = super(survey_question, self).default_get(cr, uid, fields, context) - if context.get('page_id'): - data['page_id'] = context.get('page_id', False) - return data - survey_question() @@ -755,14 +754,11 @@ class survey_response_line(osv.osv): _columns = { 'response_id': fields.many2one('survey.response', 'Answer', ondelete='cascade'), 'date_create': fields.datetime('Create Date', required=1), - 'state': fields.selection([('draft', 'Draft'), ('done', 'Answered'), ('skip', 'Skiped')], \ - 'Status', readonly=True), - 'question_id': fields.many2one('survey.question', 'Question'), - 'page_id': fields.related('question_id', 'page_id', type='many2one', \ - relation='survey.page', string='Page'), + 'state': fields.selection([('draft', 'Draft'), ('done', 'Answered'), ('skip', 'Skiped')], 'Status', readonly=True), + 'question_id': fields.many2one('survey.question', 'Question', ondelete='restrict'), + 'page_id': fields.related('question_id', 'page_id', type='many2one', relation='survey.page', string='Page', ondelete='restrict'), 'response_answer_ids': fields.one2many('survey.response.answer', 'response_id', 'Answer'), - 'response_table_ids': fields.one2many('survey.tbl.column.heading', \ - 'response_table_id', 'Answer'), + 'response_table_ids': fields.one2many('survey.tbl.column.heading', 'response_table_id', 'Answer'), 'comment': fields.text('Notes'), 'single_text': fields.char('Text', size=255), } diff --git a/addons/survey/survey_view.xml b/addons/survey/survey_view.xml index d1e4b528cc8..975de6208fe 100644 --- a/addons/survey/survey_view.xml +++ b/addons/survey/survey_view.xml @@ -6,7 +6,7 @@ - + @@ -28,7 +28,7 @@ - + @@ -47,7 +47,7 @@ - + @@ -141,7 +141,8 @@ - Edit Survey + Edit Survey + Print Survey Collect responses Fill in survey Print Statistics @@ -188,7 +189,10 @@ survey.page - + + + + @@ -196,7 +200,7 @@ - + @@ -248,6 +252,10 @@ action="action_survey_page_form" parent="menu_surveys_configuration" groups="base.group_no_one" sequence="1"/> + + survey_page_wizard_test survey.page @@ -273,14 +281,22 @@ survey_question_form survey.question - - - - + + + + + + + + + + + + @@ -385,6 +401,7 @@ + @@ -397,7 +414,7 @@ - + @@ -409,7 +426,7 @@ - + @@ -448,6 +465,10 @@ action="action_survey_question_form" parent="menu_surveys_configuration" groups="base.group_no_one" sequence="2"/> + + diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py index 7e9b1564a89..c201d9bc4ff 100644 --- a/addons/survey/wizard/survey_answer.py +++ b/addons/survey/wizard/survey_answer.py @@ -172,7 +172,7 @@ class survey_question_wiz(osv.osv_memory): for row in que_rec.answer_choice_ids: name_select = tools.ustr(que.id) + "_selection_" + tools.ustr(row.id) etree.SubElement(xml_group, 'newline') - etree.SubElement(xml_group, 'label', {'for': name_select, 'string': tools.ustr(row.answer), 'class': 'oe_survey_matrix_of_choices_row'}) + etree.SubElement(xml_group, 'label', {'for': name_select, 'string': tools.ustr(row.answer)}) etree.SubElement(xml_group, 'field', {'widget': 'radio', 'horizontal': '1', 'no_radiolabel': not first and '1' or '0', 'modifiers': readonly, 'name': name_select, 'nolabel': "1"}) selection = [] for col in que_rec.column_heading_ids: @@ -181,7 +181,7 @@ class survey_question_wiz(osv.osv_memory): name_comment = tools.ustr(que.id) + "_commentcolumn_" + tools.ustr(row.id) + "_field" if first: div_group = etree.SubElement(xml_group, 'div', {'class': 'oe_survey_matrix_of_choices_comment'}) - etree.SubElement(div_group, 'label', {'string': tools.ustr(row.answer)}) + etree.SubElement(div_group, 'label', {'string': tools.ustr(que.column_name)}) etree.SubElement(div_group, 'newline') etree.SubElement(div_group, 'field', {'modifiers': readonly, 'name': name_comment, 'nolabel': "1"}) else: @@ -430,8 +430,9 @@ class survey_question_wiz(osv.osv_memory): for que in (pag_rec and pag_rec.question_ids or []): qu_no += 1 que_rec = que_obj.browse(cr, SUPERUSER_ID, que.id, context=context) - separator_string = tools.ustr(qu_no) + "." + tools.ustr(que_rec.question) + separator_string = tools.ustr(qu_no) + ". " + tools.ustr(que_rec.question) star = que_rec.is_require_answer and '*' or '' + # display title etree.SubElement(xml_form, 'separator', {'string': star + to_xml(separator_string)}) if edit_mode: xml_group1 = etree.SubElement(xml_form, 'group', {'col': '2', 'colspan': '2'}) @@ -439,13 +440,14 @@ class survey_question_wiz(osv.osv_memory): etree.SubElement(xml_group1, 'button', {'string': '', 'icon': "gtk-edit", 'type': 'object', 'name': "action_edit_question", 'context': tools.ustr(context)}) etree.SubElement(xml_group1, 'button', {'string': '', 'icon': "gtk-delete", 'type': 'object', 'name': "action_delete_question", 'context': tools.ustr(context)}) - xml_group = etree.SubElement(xml_form, 'group', {'col': '1', 'colspan': '4'}) + xml_group = etree.SubElement(xml_form, 'group', {'col': '1', 'colspan': '4', 'class': 'oe_survey_%s' % que_rec.type}) - if que_rec.type not in ['descriptive_text']: - self._view_field_descriptive_text(cr, uid, xml_group, fields, '{"readonly": 1}', que, que_rec, context=context) - - # rendering different views readonly = response_info['readonly'] and '{"readonly": 1}' or '{}' + # display description + if que_rec.type not in ['descriptive_text']: + self._view_field_descriptive_text(cr, uid, xml_group, fields, readonly, que, que_rec, context=context) + etree.SubElement(xml_group, 'newline') + # rendering different views getattr(self, "_view_field_%s" % que_rec.type)(cr, uid, xml_group, fields, readonly, que, que_rec, context=context) if que_rec.type in ['multiple_choice_only_one_ans', 'multiple_choice_multiple_ans', 'matrix_of_choices_only_one_ans', 'matrix_of_choices_only_multi_ans', 'rating_scale'] and que_rec.is_comment_require: self._view_field_postprocessing(cr, uid, xml_group, fields, response_info['readonly'], que, que_rec, context=context)