[IMP] survey: simplify create survey, removal of unnecessary code

bzr revid: chm@openerp.com-20130227135607-0f5r0bdl12ngn18r
This commit is contained in:
Christophe Matthieu
2013-02-27 14:56:07 +01:00
parent b1e0a9f19e
commit 27f58df7bd
2 changed files with 13 additions and 130 deletions
+7 -118
View File
@@ -436,126 +436,15 @@
<field name="name">survey_question_wizard_test</field>
<field name="model">survey.question</field>
<field name="priority">20</field>
<field name="inherit_id" ref="survey_question_form"/>
<field name="arch" type="xml">
<form string="Survey Question">
<field name="question" colspan="4"/>
<field name="type" on_change="on_change_type(type)"/>
<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 col="1" colspan="4">
<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}"/>
</group>
<group colspan="4" attrs="{'invisible':[('type','not in',['matrix_of_choices_only_multi_ans', 'matrix_of_choices_only_one_ans', 'rating_scale', 'table'])]}">
<field name="column_heading_ids" colspan="4" nolabel="1" context="{'in_visible_rating_weight':in_visible_rating_weight,'in_visible_menu_choice':in_visible_menu_choice}"/>
<group colspan="4" attrs="{'invisible':[('type','not in',['table'])]}">
<field name="no_of_rows"/>
</group>
</group>
<data>
<xpath expr="//group[@colspan='4']" position="after">
<group colspan="4">
<button name="survey_save" string="Ok" type="object" icon="gtk-go-forward"/>
</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>
<group string="Validation" attrs="{'invisible':[('type','not in',['single_textbox', 'multiple_textboxes'])]}">
<group colspan="4">
<field name="is_validation_require"/>
</group>
<group col="6" colspan="4" attrs="{'invisible':[('is_validation_require','=',False)]}">
<field name="validation_type" colspan="2"/>
<group colspan="2" attrs="{'invisible':[('validation_type','!=','must_be_specific_length'), ('validation_type','!=','must_be_whole_number')]}">
<field name="validation_minimum_no" string="Between"/>
<field name="validation_maximum_no" string="and"/>
</group>
<group colspan="4" attrs="{'invisible':[('validation_type','!=','must_be_decimal_number')]}">
<field name="validation_minimum_float" string="Between"/>
<field name="validation_maximum_float" string="and"/>
</group>
<group colspan="4" attrs="{'invisible':[('validation_type','!=','must_be_date')]}">
<field name="validation_minimum_date" string="Between"/>
<field name="validation_maximum_date" string="and"/>
</group>
</group>
<group colspan="4" attrs="{'invisible':[('validation_type','!=','must_be_specific_length'),('validation_type','!=','must_be_decimal_number'),('validation_type','!=','must_be_whole_number'),('validation_type','!=','must_be_date'),('validation_type','!=','must_be_email_address')]}">
<label string="When the comment is an invalid format, display this error message" colspan="4"/>
<field name="validation_valid_err_msg" nolabel="1" colspan="4"/>
</group>
</group>
<group string="Required Answer" 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="is_require_answer"/>
<group col="6" colspan="4" attrs="{'invisible':[('is_require_answer','=',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="required_type"/>
<group colspan="2" attrs="{'invisible':[('required_type','!=','at least'),('required_type','!=','at most'),('required_type','!=','exactly')]}">
<field name="req_ans" />
</group>
<group colspan="4" attrs="{'invisible':[('required_type','!=','a range')]}">
<field name="minimum_req_ans"/>
<field name="maximum_req_ans"/>
</group>
</group>
<group colspan="4" attrs="{'invisible':[('required_type','!=','all'),('required_type','!=','at least'),('required_type','!=','at most'),('required_type','!=','exactly'),('required_type','!=','a range'),('is_require_answer','!=',True)]}">
<label string="When the question is not answered, display this error message:"/>
<field name="req_error_msg" colspan="4" nolabel="1"/>
</group>
<group colspan="4" attrs="{'invisible':[('type','not in',['numerical_textboxes'])]}">
<group colspan="2" >
<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"/>
</group>
<group colspan="4" attrs="{'invisible':[('type','not in',['rating_scale'])]}">
<field name="rating_allow_one_column_require"/>
</group>
</group>
</group>
<group string="Descriptive Text" attrs="{'invisible':[('type','not in',['descriptive_text'])]}">
<field name="descriptive_text" colspan="4" nolabel="1"/>
</group>
</group>
<group colspan="4">
<label string="" colspan="3"/>
<button name="survey_save" string="Ok" type="object" icon="gtk-go-forward"/>
</group>
</form>
</xpath>
</data>
</field>
</record>
+6 -12
View File
@@ -990,8 +990,7 @@ class survey_question_wiz(osv.osv_memory):
for key, val in context.items():
if type(key) == type(True):
context.pop(key)
view_id = self.pool.get('ir.ui.view').search(cr, uid, [('model', '=', 'survey.question'), \
('name', '=', 'survey_question_wizard_test')], context=context)
view_id = self.pool.get('ir.ui.view').search(cr, uid, [('model', '=', 'survey.question'), ('name', '=', 'survey_question_wizard_test')], context=context)
return {
'view_type': 'form',
"view_mode": 'form',
@@ -1011,8 +1010,7 @@ class survey_question_wiz(osv.osv_memory):
for key, val in context.items():
if type(key) == type(True):
context.pop(key)
view_id = self.pool.get('ir.ui.view').search(cr, uid, [('model', '=', 'survey.page'), \
('name', '=', 'survey_page_wizard_test')], context=context)
view_id = self.pool.get('ir.ui.view').search(cr, uid, [('model', '=', 'survey.page'), ('name', '=', 'survey_page_wizard_test')], context=context)
return {
'view_type': 'form',
"view_mode": 'form',
@@ -1032,8 +1030,7 @@ class survey_question_wiz(osv.osv_memory):
for key, val in context.items():
if type(key) == type(True):
context.pop(key)
view_id = self.pool.get('ir.ui.view').search(cr, uid, [('model', '=', 'survey.page'), \
('name', '=', 'survey_page_wizard_test')], context=context)
view_id = self.pool.get('ir.ui.view').search(cr, uid, [('model', '=', 'survey.page'), ('name', '=', 'survey_page_wizard_test')], context=context)
return {
'view_type': 'form',
"view_mode": 'form',
@@ -1060,8 +1057,7 @@ class survey_question_wiz(osv.osv_memory):
if not survey.page_ids:
return {'type': 'ir.actions.act_window_close'}
search_id = self.pool.get('ir.ui.view').search(cr, uid, [('model', '=', 'survey.question.wiz'), \
('name', '=', 'Survey Search')], context=context)
search_id = self.pool.get('ir.ui.view').search(cr, uid, [('model', '=', 'survey.question.wiz'), ('name', '=', 'Survey Search')], context=context)
surv_name_wiz = self.pool.get('survey.name.wiz')
surv_name_wiz.write(cr, uid, [context.get('sur_name_id', False)], \
{'transfer': True, 'page_no': context.get('page_number', False)})
@@ -1084,8 +1080,7 @@ class survey_question_wiz(osv.osv_memory):
for key, val in context.items():
if type(key) == type(True):
context.pop(key)
view_id = self.pool.get('ir.ui.view').search(cr, uid, [('model', '=', 'survey.question'), \
('name', '=', 'survey_question_wizard_test')], context=context)
view_id = self.pool.get('ir.ui.view').search(cr, uid, [('model', '=', 'survey.question'), ('name', '=', 'survey_question_wizard_test')], context=context)
return {
'view_type': 'form',
"view_mode": 'form',
@@ -1109,8 +1104,7 @@ class survey_question_wiz(osv.osv_memory):
que_obj = self.pool.get('survey.question')
que_obj.unlink(cr, uid, [context.get('question_id', False)])
search_id = self.pool.get('ir.ui.view').search(cr, uid, [('model', '=', 'survey.question.wiz'), \
('name', '=', 'Survey Search')], context=context)
search_id = self.pool.get('ir.ui.view').search(cr, uid, [('model', '=', 'survey.question.wiz'), ('name', '=', 'Survey Search')], context=context)
surv_name_wiz = self.pool.get('survey.name.wiz')
surv_name_wiz.write(cr, uid, [context.get('sur_name_id', False)], \
{'transfer': True, 'page_no': context.get('page_number', 0)})