[IMP] Admin views

bzr revid: rim@openerp.com-20131031140545-eld3dj1daj5etvcb
This commit is contained in:
Richard Mathot (OpenERP) 2013-10-31 15:05:45 +01:00
parent 0221fa91f7
commit 3d1589a227
3 changed files with 79 additions and 142 deletions

View File

@ -1,11 +0,0 @@
openerp.survey = function(openerp) {
openerp.web_kanban.KanbanRecord.include({
on_card_clicked: function(e) {
if (this.view.dataset.model === 'survey.survey') {
this.$('.oe_survey_fill a:first').click();
} else {
this._super.apply(this, arguments);
}
},
});
};

View File

@ -360,10 +360,6 @@ class survey_question(osv.osv):
'description': fields.text('Description', help="Use this field to add \
additional explanations about your question", translate=True,
oldname='descriptive_text'),
'display': fields.selection(
[('horizontal', 'Horizontal'),
('vertical', 'Vertical')],
'Display'),
# Answer
'type': fields.selection([('free_text', 'Free Text'),
@ -374,7 +370,8 @@ class survey_question(osv.osv):
('simple_choice_scale', 'One choice on a scale'),
('simple_choice_dropdown', 'One choice in a menu'),
('multiple_choice', 'Some choices in checkboxes'),
('vector', 'Multi-questions'),
('vector',
'Multi-questions'),
('matrix', 'Matrix')
], 'Question Type', required=1),
@ -393,12 +390,12 @@ class survey_question(osv.osv):
'validation_required': fields.boolean('Validate entry',
oldname='is_validation_require'),
'validation_type': fields.selection([
('has_length', 'Must Be Specific Length'),
('is_integer', 'Must Be A Whole Number'),
('is_decimal', 'Must Be A Decimal Number'),
('is_date', 'Must Be A Date'),
('is_email', 'Must Be An Email Address')
], 'Text Validation'),
('has_length', 'Must have a specific length'),
('is_integer', 'Must be an integer'),
('is_decimal', 'Must be a decimal number'),
('is_date', 'Must be a date'),
('is_email', 'Must be an email address')
], 'Validation type'),
'validation_length': fields.integer('Specific length'),
'validation_min_float_value': fields.float('Minimum value'),
'validation_max_float_value': fields.float('Maximum value'),
@ -409,25 +406,14 @@ class survey_question(osv.osv):
'validation_error_msg': fields.char("Error message if validation \
fails", oldname='validation_valid_err_msg'),
'numeric_required_sum': fields.integer('Sum of all choices'),
'numeric_required_sum_err_msg': fields.text('Error message',
translate=True),
# 'in_visible_rating_weight': fields.boolean('Is Rating Scale nvisible?'),
# 'in_visible_menu_choice': fields.boolean('Is Menu Choice Invisible?'),
# 'in_visible_answer_type': fields.boolean('Is Answer Type Invisible?'),
# 'comment_column': fields.boolean('Add comment column in matrix'),
# 'column_name': fields.char('Column Name', translate=True),
# 'no_of_rows': fields.integer('No of Rows'),
# Constraints on number of answers
'constr_mandatory': fields.boolean('Mandatory question',
oldname="is_require_answer"),
'constr_type': fields.selection([('all', 'All'),
('at least', 'At Least'),
('at most', 'At Most'),
('exactly', 'Exactly'),
('a range', 'A Range')],
'constr_type': fields.selection([('all', 'all'),
('at least', 'at least'),
('at most', 'at most'),
('exactly', 'exactly'),
('a range', 'a range')],
'Constraint on answers number', oldname='required_type'),
'constr_maximum_req_ans': fields.integer('Maximum Required Answer',
oldname='maximum_req_ans'),
@ -439,49 +425,18 @@ 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'),
#'req_error_msg': lambda s, cr, uid, c: _('This question requires an answer.'),
'type': 'free_text',
'validation_error_msg': lambda s, cr, uid, c: _('The answer you entered has an invalid format.'),
'constr_type': 'at least',
'constr_minimum_req_ans': 1,
#'comment_field_type': 'char',
#'comment_label': lambda s, cr, uid, c: _('Other (please specify)'),
#'comment_valid_type': 'do_not_validate',
#'comment_valid_err_msg': lambda s, cr, uid, c: _('The comment you entered is in an invalid format.'),
'constr_error_msg': lambda s, cr, uid, c:
_('This question requires an answer.'),
'validation_required': 'False',
#'validation_valid_err_msg': lambda s, cr, uid, c: _('The comment you entered is in an invalid format.'),
#'numeric_required_sum_err_msg': lambda s, cr, uid, c: _('The choices need to add up to [enter sum here].'),
#'make_comment_field_err_msg': lambda s, cr, uid, c: _('Please enter a comment.'),
#'in_visible_answer_type': 1
}
def on_change_type(self, cr, uid, ids, type, context=None):
''' Updates the editing view in relation with the question type '''
val = {}
val['is_require_answer'] = False
val['is_comment_require'] = False
val['is_validation_require'] = False
val['comment_column'] = False
if type in ['multiple_textboxes_diff_type']:
val['in_visible_answer_type'] = False
return {'value': val}
if type in ['rating_scale']:
val.update({'in_visible_rating_weight': False,
'in_visible_menu_choice': True})
return {'value': val}
elif type in ['single_textbox']:
val.update({'in_visible_rating_weight': True,
'in_visible_menu_choice': True})
return {'value': val}
else:
val.update({'in_visible_rating_weight': True,
'in_visible_menu_choice': True,
'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,

View File

@ -415,116 +415,109 @@
</group>
<!-- Comments -->
<group colspan="1" string="Comments">
<group colspan="1" string="Comments" attrs="{'invisible':[('type','in',['freetext'])]}">
<field name='comments_allowed' />
<group colspan="2" attrs="{'invisible':[('comments_allowed','=',False)]}">
<field name='comment_count_as_answer' />
</group>
</group>
<!-- <group string="Comment Field" attrs="{'invisible':[('type','not in',['multiple_choice_only_one_ans', 'multiple_choice_multiple_ans', 'matrix_of_choices_only_multi_ans', 'matrix_of_choices_only_one_ans', 'rating_scale'])]}">
<group colspan="4">
<field name="is_comment_require"/>
</group>
<group attrs="{'invisible':[('is_comment_require','=',False)]}">
<group col="4" colspan="4">
<field name="comment_field_type" colspan="1"/>
<group colspan="2" attrs="{'invisible':[('comment_field_type','!=','char'),('comment_field_type','!=','text')]}">
<field colspan="2" name="comment_label" />
</group>
</group>
<group col="6" colspan="4" attrs="{'invisible':[('comment_field_type','!=','char'),('comment_field_type','!=','text')]}">
<field name="comment_valid_type" colspan="2"/>
<group colspan="2" attrs="{'invisible':[('comment_valid_type','!=','must_be_specific_length'), ('comment_valid_type','!=','must_be_whole_number')]}">
<field name="comment_minimum_no" string="Between"/>
<field name="comment_maximum_no" string="and"/>
</group>
<group colspan="4" attrs="{'invisible':[('comment_valid_type','!=','must_be_decimal_number')]}">
<field name="comment_minimum_float" string="Between"/>
<field name="comment_maximum_float" string="and"/>
</group>
<group colspan="4" attrs="{'invisible':[('comment_valid_type','!=','must_be_date')]}">
<field name="comment_minimum_date" string="Between"/>
<field name="comment_maximum_date" string="and"/>
</group>
<group colspan="4" attrs="{'invisible':[('comment_valid_type','!=','must_be_specific_length'),('comment_valid_type','!=','must_be_decimal_number'),('comment_valid_type','!=','must_be_whole_number'),('comment_valid_type','!=','must_be_date'),('comment_valid_type','!=','must_be_email_address')]}">
<label string="When the comment is an invalid format, display this error message" colspan="4"/>
<field name="comment_valid_err_msg" nolabel="1" colspan="4"/>
</group>
</group>
</group>
</group> -->
<!-- <group attrs="{'invisible':[('type','not in',['matrix_of_choices_only_one_ans', 'rating_scale'])]}">
<field name="comment_column"/>
<group colspan="2" attrs="{'invisible':[('comment_column','!=',True)]}">
<field name="column_name" colspan="2"/>
</group>
</group>
-->
<!-- Answer validation -->
<group colspan="1" string="Answer Validation" attrs="{'invisible':[('type','not in',['textbox','numerical_box','datetime'])]}">
<group>
<field name="validation_required"/>
<group attrs="{'invisible':[('validation_required','=',False)]}">
<group colspan="2" attrs="{'invisible':[('validation_required','=',False)]}">
<field name="validation_type" />
<group attrs="{'invisible':[('validation_type','!=','has_length')]}">
<group colspan="2" attrs="{'invisible':[('validation_type','!=','has_length')]}">
<field name="validation_length" string="Length"/>
</group>
<group attrs="{'invisible':[('validation_type','!=','is_decimal')]}">
<group colspan="2" attrs="{'invisible':[('validation_type','!=','is_decimal')]}">
<field name="validation_min_float_value" string="between"/>
<field name="validation_max_float_value" string="and"/>
</group>
<group attrs="{'invisible':[('validation_type','!=','is_integer')]}">
<group colspan="2" attrs="{'invisible':[('validation_type','!=','is_integer')]}">
<field name="validation_min_int_value" string="between"/>
<field name="validation_max_int_value" string="and"/>
</group>
<group attrs="{'invisible':[('validation_type','!=','is_date')]}">
<group colspan="2" 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>
<!-- Question validation -->
<group colspan="2" string="Question required" attrs="{'invisible':[('type','not in',['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', 'single_textbox', 'comment', 'multiple_textboxes_diff_type'])]}">
<field name="constr_mandatory"/>
<group col="6" colspan="4" attrs="{'invisible':[('constr_mandatory','=',False)]}">
<group colspan="4" attrs="{'invisible':[('type','not 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', 'multiple_textboxes_diff_type'])]}">
<field name="constr_type"/>
<!-- <group colspan="2" attrs="{'invisible':[('constr_type','!=','at least'),('constr_type','!=','at most'),('constr_type','!=','exactly')]}">
<field name="req_ans" />
</group> -->
<group colspan="4" attrs="{'invisible':[('constr_type','!=','a range')]}">
'type': fields.selection([('free_text', 'Free Text'),
('textbox', 'Text box'),
('numerical_box', 'Numerical box'),
('datetime', 'Date and Time'),
('checkbox', 'Checkbox'),
('simple_choice_scale', 'One choice on a scale'),
('simple_choice_dropdown', 'One choice in a menu'),
('multiple_choice', 'Some choices in checkboxes'),
('vector', 'Multi-questions'),
('matrix', 'Matrix')
], 'Question Type', required=1),
'constr_mandatory': fields.boolean('Mandatory question',
oldname="is_require_answer"),
'constr_type': fields.selection([('all', 'all'),
('at least', 'at least'),
('at most', 'at most'),
('exactly', 'exactly'),
('a range', 'a range')],
'Constraint on answers number', oldname='required_type'),
'constr_maximum_req_ans': fields.integer('Maximum Required Answer',
oldname='maximum_req_ans'),
'constr_minimum_req_ans': fields.integer('Minimum Required Answer',
oldname='minimum_req_ans'),
'constr_error_msg': fields.char("Error message if constraints fails",
oldname='req_error_msg'),
<group colspan="1" string="Question required">
<field name="constr_mandatory" string="Is this question mandatory?"/>
<group colspan="2" attrs="{'invisible':[('constr_mandatory','=',False)]}">
<field name="constr_type" string="Users must answer..."/>
<group attrs="{'invisible':[('type','not 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', 'multiple_textboxes_diff_type'])]}">
<group attrs="{'invisible':[('constr_type','!=','a range')]}">
<field name="constr_minimum_req_ans"/>
<field name="constr_maximum_req_ans"/>
</group>
</group>
<group colspan="4" attrs="{'invisible':[('constr_type','!=','all'),('constr_type','!=','at least'),('constr_type','!=','at most'),('constr_type','!=','exactly'),('constr_type','!=','a range'),('constr_mandatory','!=',True)]}">
<group attrs="{'invisible':[('constr_type','!=','all'),('constr_type','!=','at least'),('constr_type','!=','at most'),('constr_type','!=','exactly'),('constr_type','!=','a range'),('constr_mandatory','!=',True)]}">
<label string="When the question is not answered, display this error message:"/>
<field name="constr_error_msg" colspan="4" nolabel="1"/>
<field name="constr_error_msg" nolabel="1"/>
</group>
<group colspan="4" attrs="{'invisible':[('type','not in',['numerical_textboxes'])]}">
<group colspan="2" >
<group attrs="{'invisible':[('type','not in',['numerical_textboxes'])]}">
<group >
<field name="numeric_required_sum"/>
</group>
<newline/>
<label string="When the choices do not add up correctly, display this error message"/>
<field name="numeric_required_sum_err_msg" colspan="4" nolabel="1"/>
<field name="numeric_required_sum_err_msg" nolabel="1"/>
</group>
<!-- <group colspan="4" attrs="{'invisible':[('type','not in',['rating_scale'])]}">
<field name="rating_allow_one_column_require"/>
</group> -->
</group>
</group>
</group>
</group>
</sheet>
</form>
</field>