[IMP] survey: css and edit
bzr revid: chm@openerp.com-20130306100508-dtkjg1wxdhiogu6d
This commit is contained in:
@@ -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;
|
||||
}
|
||||
+16
-20
@@ -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),
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<menuitem name="Surveys" id="menu_surveys" parent="base.menu_tools" sequence="2" groups="base.group_tool_user,base.group_tool_manager,base.group_survey_user"/>
|
||||
|
||||
<menuitem name="Configuration" id="menu_surveys_configuration" parent="menu_surveys" sequence="3" groups="base.group_tool_manager"/>
|
||||
<menuitem name="Configuration" id="menu_surveys_configuration" parent="menu_surveys" sequence="50" groups="base.group_tool_manager"/>
|
||||
|
||||
<menuitem name="Reporting" parent="base.menu_tools" id="base.menu_lunch_reporting" sequence="6"/>
|
||||
<menuitem name="Reporting" id="menu_reporting" parent="menu_surveys" sequence="60"/>
|
||||
@@ -28,7 +28,7 @@
|
||||
<button name="survey_cancel" string="Cancel" states="draft" type="object"/>
|
||||
<field name="state" widget="statusbar" nolabel="1" attrs="{'invisible':[('state','=','cancel')]}" statusbar_visible="draft,open,close"/>
|
||||
</header>
|
||||
<sheet>
|
||||
<sheet class="oe_survey">
|
||||
<div class="oe_button_box oe_right">
|
||||
<button name="action_print_survey" states="draft,open,close,cancel" string="Print Answer" type="object"/>
|
||||
<button name="edit_survey" states="draft,open,close,cancel" string="Edit Survey" type="object"/>
|
||||
@@ -47,7 +47,7 @@
|
||||
<field name="public_url" widget="url"/>
|
||||
</group>
|
||||
</group>
|
||||
<field name="page_ids" colspan="4" mode="tree" attrs="{'readonly':[('state','=','close')]}">
|
||||
<field name="page_ids" colspan="4" mode="tree" attrs="{'readonly':[('state','=','close')]}" context="{'default_survey_id': active_id}">
|
||||
<tree string="Survey Question">
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="title"/>
|
||||
@@ -141,7 +141,8 @@
|
||||
</div>
|
||||
<br/>
|
||||
<ul>
|
||||
<li t-if="widget.view.is_action_enabled('edit')"><a name="edit_survey" string="Edit Survey" type="object">Edit Survey</a></li>
|
||||
<li t-if="widget.view.is_action_enabled('edit')"><a name="edit_survey" type="object">Edit Survey</a></li>
|
||||
<li t-if="widget.view.is_action_enabled('edit')"><a name="action_print_survey" type="object">Print Survey</a></li>
|
||||
<li t-if="record.state.raw_value === 'open' and widget.view.is_action_enabled('edit')"><a name="action_survey_sent" type="object">Collect responses</a></li>
|
||||
<li><a t-if="record.state.raw_value === 'open'" name="fill_survey" type="object">Fill in survey</a></li>
|
||||
<li t-if="record.tot_comp_survey.raw_value and widget.view.is_action_enabled('edit')"><a name="print_statistics" type="object">Print Statistics</a></li>
|
||||
@@ -188,7 +189,10 @@
|
||||
<field name="model">survey.page</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Survey Page" version="7.0">
|
||||
<sheet>
|
||||
<sheet class="oe_survey">
|
||||
<group col="2" invisible="context.get('edit')">
|
||||
<field name="survey_id"/>
|
||||
</group>
|
||||
<label for="title" class="oe_edit_only"/>
|
||||
<h1>
|
||||
<field name="title"/>
|
||||
@@ -196,7 +200,7 @@
|
||||
<group colspan="4" col="1">
|
||||
<field name="note" nolabel="1" placeholder="Description on the survey page..."/>
|
||||
<field name="question_ids" nolabel="1" mode="tree">
|
||||
<tree string="Survey Question">
|
||||
<tree string="Survey Question" context="{'default_page_id': active_id}">
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="question"/>
|
||||
<field name="type"/>
|
||||
@@ -248,6 +252,10 @@
|
||||
action="action_survey_page_form" parent="menu_surveys_configuration"
|
||||
groups="base.group_no_one" sequence="1"/>
|
||||
|
||||
<menuitem name="Surveys Pages" id="menu_survey_page_form1"
|
||||
action="action_survey_page_form" parent="menu_surveys"
|
||||
groups="base.group_tool_manager" sequence="4"/>
|
||||
|
||||
<record model="ir.ui.view" id="survey_page_wizard_test1">
|
||||
<field name="name">survey_page_wizard_test</field>
|
||||
<field name="model">survey.page</field>
|
||||
@@ -273,14 +281,22 @@
|
||||
<field name="name">survey_question_form</field>
|
||||
<field name="model">survey.question</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Survey Question">
|
||||
<field name="question" colspan="4"/>
|
||||
<field name="descriptive_text" colspan="4"/>
|
||||
<field name="type" on_change="on_change_type(type)"/>
|
||||
<form string="Survey Question" version="7.0">
|
||||
<sheet class="oe_survey">
|
||||
<field name="in_visible_rating_weight" invisible="1"/>
|
||||
<field name="in_visible_menu_choice" invisible="1"/>
|
||||
<field name="in_visible_answer_type" invisible="1"/>
|
||||
<group colspan="4" col="1">
|
||||
<group col="2" invisible="context.get('edit')">
|
||||
<field name="tot_resp"/>
|
||||
<field name="survey_id" readonly="1"/>
|
||||
<field name="page_id" on_change="on_change_page_id(page_id)"/>
|
||||
</group>
|
||||
<group col="2">
|
||||
<field name="type" on_change="on_change_type(type)"/>
|
||||
<field name="question" nolabel="1" colspan="2"/>
|
||||
<field name="descriptive_text" nolabel="1" colspan="2"/>
|
||||
</group>
|
||||
<group string="Answer" attrs="{'invisible':[('type','not in',['multiple_textboxes_diff_type', 'multiple_choice_only_one_ans', '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', 'table'])]}">
|
||||
<group colspan="4" attrs="{'invisible':[('type','=','table')]}">
|
||||
<field name="answer_choice_ids" nolabel="1" colspan="4" context="{'in_visible_answer_type': in_visible_answer_type}"/>
|
||||
@@ -385,6 +401,7 @@
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
@@ -397,7 +414,7 @@
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="question"/>
|
||||
<field name="page_id"/>
|
||||
<field name="survey"/>
|
||||
<field name="survey_id"/>
|
||||
<field name="type"/>
|
||||
</tree>
|
||||
</field>
|
||||
@@ -409,7 +426,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Question">
|
||||
<field name="question" string="Question"/>
|
||||
<field name="survey"/>
|
||||
<field name="survey_id"/>
|
||||
<field name="type"/>
|
||||
<field name="page_id"/>
|
||||
<group expand="0" string="Group By...">
|
||||
@@ -448,6 +465,10 @@
|
||||
action="action_survey_question_form" parent="menu_surveys_configuration"
|
||||
groups="base.group_no_one" sequence="2"/>
|
||||
|
||||
<menuitem name="Surveys Questions" id="menu_survey_question_form1"
|
||||
action="action_survey_question_form" parent="menu_surveys"
|
||||
groups="base.group_tool_manager" sequence="3"/>
|
||||
|
||||
<!--
|
||||
Survey Answer
|
||||
-->
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user