<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <!-- Top menu item -->
        <menuitem name="Tools" id="base.menu_tools" sequence="120" groups="base.group_tool_user"/>

        <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="Reporting" parent="base.menu_tools"
            id="base.menu_lunch_reporting" sequence="6"/>
        <menuitem name="Reporting" id="menu_reporting" parent="menu_surveys" sequence="60"/>
        <menuitem id="base.next_id_10" name="Survey" parent="base.menu_reporting" sequence="1" groups="base.group_survey_user"/>

        <!--
            Survey
        -->

        <record model="ir.ui.view" id="survey_form">
            <field name="name">survey_form</field>
            <field name="model">survey</field>
            <field name="arch" type="xml">
                <form string="Survey" version="7.0">
                <header>
                    <button name="survey_open" string="Open" states="cancel,close" type="object"/>
                    <button name="survey_close" string="Close" states="open" type="object" class="oe_highlight"/>
                    <button name="survey_cancel" string="Cancel Survey" states="open" type="object"/>
                    <field name="state" widget="statusbar" statusbar_visible="open,close"/>
                </header>
                <sheet>
                    <div class="oe_button_box oe_right">
                        <button name="test_survey" states="open,draft,close,cancel" string="Test Survey" type="object" icon="gtk-new" context="{'survey_id': active_id}" attrs="{'invisible':[('id','=',0)]}"/>
                        <button name="fill_survey" states="open" string="Answer Survey" type="object" icon="gtk-execute" context="{'survey_id': active_id}" attrs="{'invisible':[('state','!=','open')]}"/>
                        <button name="action_print_survey" states="open,draft,close,cancel" string="Print Answer" type="object"/>
                        <button name="edit_survey" states="open,draft,close,cancel"
                            string="Edit Survey" type="object" context="{'active':True,'edit' : True,'survey_id': active_id}"/>

                    </div>
                    <div class="oe_title">
                        <label for="title" class="oe_edit_only"/>
                        <h1>
                            <field name="title" attrs="{'readonly':[('state','=','close')]}"/>
                        </h1>
                    </div>
                    <group>
                        <group>
                            <field name="id" invisible="1"/>
                            <field name="responsible_id" class="oe_inline" attrs="{'readonly':[('state','=','close')]}"/>
                            <field name="type" attrs="{'readonly':[('state','=','close')]}" class="oe_inline"/>
                            <field name="send_response" attrs="{'readonly':[('state','=','close')]}"/>
                        </group>
                        <group>
                            <field name="max_response_limit" attrs="{'readonly':[('state','=','close')]}"/>
                            <field name="response_user" attrs="{'readonly':[('state','=','close')]}"/>
                        </group>
                     </group>
                     <notebook>
                        <page string="Survey Details">
                            <field name="page_ids" colspan="4" mode="tree" attrs="{'readonly':[('state','=','close')]}">
                                <form string="Survey Page" version="7.0">
                                    <sheet>
                                    <label for="title" class="oe_edit_only"/>
                                    <h1>
                                        <field name="title"/>
                                    </h1>
                                    <field name="note" placeholder="Description on the survey page..."/>
                                    <newline/>
                                    <group>
                                        <label for="question_ids"/>
                                        <newline/>
                                        <field name="question_ids" nolabel="1">
                                            <form string="Survey Question">
                                                <group>
                                                    <group>
                                                        <field name="question"/>
                                                        <field name="type" on_change="on_change_type(type)"/>
                                                    </group>
                                                </group>
                                                <newline/>
                                                <group>
                                                <field name="in_visible_rating_weight" invisible="1"/>
                                                <field name="in_visible_menu_choice" invisible="1"/>
                                                <field name="in_visible_answer_type" invisible="1"/>
                                                <notebook colspan="4">
                                                    <page string="Options">
                                                        <group attrs="{'invisible':[('type','!=','multiple_textboxes_diff_type'),('type','!=','multiple_choice_only_one_ans'), ('type','!=','multiple_choice_multiple_ans'),('type','!=','matrix_of_choices_only_one_ans'),('type','!=','matrix_of_choices_only_multi_ans'),('type','!=','matrix_of_drop_down_menus'),('type','!=','rating_scale'),('type','!=','multiple_textboxes'),('type','!=','numerical_textboxes'),('type','!=','date'),('type','!=','date_and_time'),('type','!=','table')]}" string="Answer">
                                                           <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','!=','matrix_of_choices_only_multi_ans'),('type','!=','matrix_of_choices_only_one_ans'),('type','!=','matrix_of_drop_down_menus'),('type','!=','rating_scale'),('type','!=','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','!=','table')]}">
                                                                   <field name="no_of_rows"/>
                                                                </group>
                                                           </group>
                                                        </group>
                                                        <newline/>
                                                        <group  attrs="{'invisible':[('type','!=','multiple_choice_only_one_ans'), ('type','!=','multiple_choice_multiple_ans'), ('type','!=','matrix_of_choices_only_multi_ans'),('type','!=','matrix_of_choices_only_one_ans'),('type','!=','matrix_of_drop_down_menus'),('type','!=','rating_scale')]}">
                                                            <separator string="Comment Field" colspan="4"/>
                                                            <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>
                                                        <newline/>
                                                        <group attrs="{'invisible':[('type','!=','matrix_of_choices_only_one_ans'),('type','!=','rating_scale')]}">
                                                            <field name="comment_column"/>
                                                            <group colspan="2" attrs="{'invisible':[('comment_column','!=',True)]}">
                                                                <field name="column_name" colspan="2"/>
                                                            </group>
                                                        </group>
                                                        <newline/>
                                                        <group attrs="{'invisible':[('type','!=','single_textbox'), ('type','!=','multiple_textboxes')]}">
                                                            <separator string="Validation" colspan="4"/>
                                                            <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>
                                                        <newline/>
                                                        <group attrs="{'invisible':[('type','!=','multiple_choice_only_one_ans'), ('type','!=','multiple_choice_multiple_ans'),('type','!=','matrix_of_choices_only_one_ans'),('type','!=','matrix_of_choices_only_multi_ans'),('type','!=','matrix_of_drop_down_menus'),('type','!=','rating_scale'),('type','!=','multiple_textboxes'),('type','!=','numerical_textboxes'),('type','!=','date'),('type','!=','date_and_time'),('type','!=','single_textbox'),('type','!=','comment'),('type','!=','multiple_textboxes_diff_type')]}">
                                                            <separator string="Required Answer" colspan="4"/>
                                                            <newline/>
                                                            <field name="is_require_answer"/>
                                                            <group col="6" colspan="4" attrs="{'invisible':[('is_require_answer','=',False)]}">
                                                                <group colspan="4" attrs="{'invisible':[('type','!=','multiple_choice_multiple_ans'),('type','!=','matrix_of_choices_only_one_ans'),('type','!=','matrix_of_choices_only_multi_ans'),('type','!=','matrix_of_drop_down_menus'),('type','!=','rating_scale'),('type','!=','multiple_textboxes'),('type','!=','numerical_textboxes'),('type','!=','date'),('type','!=','date_and_time'),('type','!=','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','!=','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','!=','rating_scale')]}">
                                                                    <field name="rating_allow_one_column_require"/>
                                                                </group>
                                                            </group>
                                                        </group>
                                                        <newline/>
                                                        <group attrs="{'invisible':[('type','!=','descriptive_text')]}">
                                                            <separator string="Descriptive Text" colspan="4"/>
                                                            <field name="descriptive_text" colspan="4" nolabel="1"/>
                                                        </group>
                                                    </page>
                                                </notebook>
                                                </group>
                                            </form>
                                            <tree string="Survey Question">
                                                <field name="sequence" string="Seq"/>
                                                <field name="question"/>
                                                <field name="answer_choice_ids"/>
                                            </tree>
                                        </field>
                                    </group>
                                    </sheet>
                                    </form>
                                </field>
                            <field name="note" placeholder="Survey description..." attrs="{'readonly':[('state','=','close')]}"/>
                        </page>
                        <page string="Invited User">
                            <field name="invited_user_ids" readonly="1"/>
                        </page>
                        <page string="History">
                            <group>
                                <group>
                                    <field name="date_open"/>
                                    <field name="date_close"/>
                                </group>
                                <group>
                                    <field name="tot_start_survey"/>
                                    <field name="tot_comp_survey"/>
                                </group>
                            </group>
                            <field name="history" colspan="4">
                                <tree string="History">
                                    <field name="date"/>
                                    <field name="user_id"/>
                                </tree>
                                <form string="History">
                                    <field name="date"/>
                                    <field name="user_id"/>
                                </form>
                           </field>
                        </page>
                    </notebook>
                </sheet>
                </form>
            </field>
        </record>

        <record model ="ir.ui.view" id= "survey_tree">
            <field name="name">survey_tree</field>
            <field name="model">survey</field>
            <field name="arch" type="xml">
                <tree colors="gray:state == 'close'" string="Survey">
                    <field name="title"/>
                    <field name="type"/>
                    <field name="responsible_id"/>
                    <field name="date_open"  string="Open Date"/>
                    <field name="tot_start_survey" string="Started"/>
                    <field name="tot_comp_survey" string="Completed"/>
                    <field name="state"/>
                    <button name="test_survey" states="open,draft,close,cancel"
                        string="Test Survey" type="object" icon="gtk-new"
                        context="{'survey_id': active_id}"/>
                    <button name="fill_survey" states="open"
                        string="Answer Survey" type="object" icon="gtk-execute" context="{'survey_id': active_id}" attrs="{'invisible':[('state','!=','open')]}"/>                   
                    <button name="action_print_survey" states="open,draft,close,cancel"
                                    string="Print Answer" type="object" icon="gtk-print"/>
                </tree>
            </field>
        </record>

        <record id="survey_search" model="ir.ui.view">
            <field name="name">survey_search</field>
            <field name="model">survey</field>
            <field name="arch" type="xml">
                <search string="Search Survey">
                    <field name="title" string="Survey"/>
                    <field name="type"/>
                    <filter icon="terp-document-new" string="New" domain="[('state','=', 'draft')]" help="All New Survey"/>
                    <filter icon="terp-camera_test" string="Open" domain="[('state','=','open')]" help="All Open Survey"/>
                    <separator/>
                    <filter string="My Survey(s)" icon="terp-personal" domain="[('responsible_id','=',uid)]" help="My Survey(s)"/>
                    <field name="responsible_id"/>
                   <group expand="0" string="Group By...">
                       <filter string="Responsible" icon="terp-personal" domain="[]"  context="{'group_by':'responsible_id'}"/>
                       <filter string="Type" icon="terp-stock_symbol-selection" domain="[]"  context="{'group_by':'type'}"/>
                       <filter string="Status" icon="terp-stock_effects-object-colorize" domain="[]"  context="{'group_by':'state'}"/>
                   </group>
               </search>
            </field>
        </record>

        <record model="ir.ui.view" id="view_survey_kanban">
            <field name="name">event.survey.kanban</field>
            <field name="model">survey</field>
            <field name="arch" type="xml">
                <kanban>
                    <field name="title"/>
                    <field name="date_open"/>
                    <field name="tot_comp_survey"/>
                    <field name="max_response_limit"/>
                    <field name="responsible_id"/>
                    <field name="color"/>
                    <templates>
                        <t t-name="kanban-box">
                            <div t-attf-class="oe_kanban_color_#{kanban_getcolor(record.color.raw_value)} oe_kanban_card oe_kanban_survey">
                                <div class="oe_dropdown_toggle oe_dropdown_kanban">
                                    <span class="oe_e">i</span>
                                    <ul class="oe_dropdown_menu">
                                        <t t-if="widget.view.is_action_enabled('edit')"><li><a type="edit">Edit...</a></li></t>
                                        <t t-if="widget.view.is_action_enabled('delete')"><li><a type="delete">Delete</a></li></t>
                                        <li><ul class="oe_kanban_colorpicker" data-field="color"/></li>
                                    </ul>
                                </div>
                                <div class="oe_kanban_content">
                                    <h3 class="oe_kanban_ellipsis"><t t-esc="record.title.raw_value.toString()"></t></h3>
                                    <div>
                                        Answers: <field name="tot_comp_survey"/>
                                        <t t-if="record.max_response_limit.raw_value > 0"> / <field name="max_response_limit"/></t>
                                    </div>
                                    <br/>
                                    <a name="fill_survey" type="object">Answer Survey</a>
                                    <img t-att-src="kanban_image('res.users', 'image_small', record.responsible_id.raw_value)" t-att-title="record.responsible_id.value" width="24" height="24" class="oe_kanban_avatar oe_right"/>
                                </div>
                            </div>
                        </t>
                    </templates>
                </kanban>
            </field>
        </record>

        <record model="ir.actions.act_window" id="action_survey_form1">
            <field name="name">Surveys</field>
            <field name="res_model">survey</field>
            <field name="view_type">form</field>
            <field name="view_mode">kanban,tree,form</field>
            <field name="view_id" ref="view_survey_kanban"></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><p>
                You can create survey for different purposes: recruitment
                interviews, employee's periodical evaluations, marketing
                campaigns, etc.
              </p><p>
                A survey is made of pages containing questions
                of several types: text, multiple choices, etc.
              </p>
            </field>
        </record>


        <menuitem name="Surveys" id="menu_survey_form"
            action="action_survey_form1" parent="menu_surveys"
            groups="base.group_tool_manager" sequence="1"/>

        <!--
            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">
                    <sheet>
                        <label for="title" class="oe_edit_only"/>
                        <h1>
                            <field name="title"/>
                        </h1>
                        <group colspan="4">
                            <field name="survey_id"/>
                            <field name="sequence"/>
                        </group>
                        <group colspan="4">
                            <field name="note" nolabel="1" placeholder="Description on the survey page..."/>
                        </group>
                        <group col="4">
                            <label for="question_ids"/>
                            <newline/>
                            <field name="question_ids" nolabel="1">
                            <form string="Survey Question">
                                <group>
                                    <group>
                                        <field name="question" select="1"/>
                                        <field name="type" on_change="on_change_type(type)"/>
                                    </group>
                                    <group>
                                        <field name="sequence" invisible="1"/>
                                        <field name="tot_resp" invisible="1"/>
                                        <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>
                                    <newline/>
                                    <notebook colspan="4">
                                        <page string="Options">
                                            <group attrs="{'invisible':[('type','!=','multiple_textboxes_diff_type'),('type','!=','multiple_choice_only_one_ans'), ('type','!=','multiple_choice_multiple_ans'),('type','!=','matrix_of_choices_only_one_ans'),('type','!=','matrix_of_choices_only_multi_ans'),('type','!=','matrix_of_drop_down_menus'),('type','!=','rating_scale'),('type','!=','multiple_textboxes'),('type','!=','numerical_textboxes'),('type','!=','date'),('type','!=','date_and_time'),('type','!=','table')]}" string="Answer" col="4">
                                               <group attrs="{'invisible':[('type','=','table')]}">
                                                   <field name="answer_choice_ids" nolabel="1" context="{'in_visible_answer_type': in_visible_answer_type}"/>
                                               </group>
                                               <group attrs="{'invisible':[('type','!=','matrix_of_choices_only_multi_ans'),('type','!=','matrix_of_choices_only_one_ans'),('type','!=','matrix_of_drop_down_menus'),('type','!=','rating_scale'),('type','!=','table')]}">
                                                   <field name="column_heading_ids" nolabel="1" context="{'in_visible_rating_weight':in_visible_rating_weight,'in_visible_menu_choice':in_visible_menu_choice}"/>
                                                    <group attrs="{'invisible':[('type','!=','table')]}">
                                                       <field name="no_of_rows"/>
                                                    </group>
                                               </group>
                                            </group>
                                            <newline/>
                                            <group  attrs="{'invisible':[('type','!=','multiple_choice_only_one_ans'), ('type','!=','multiple_choice_multiple_ans'), ('type','!=','matrix_of_choices_only_multi_ans'),('type','!=','matrix_of_choices_only_one_ans'),('type','!=','matrix_of_drop_down_menus'),('type','!=','rating_scale')]}" string="Comment Field" col="4">
                                                <group>
                                                    <field name="is_comment_require"/>
                                                </group>
                                                <group attrs="{'invisible':[('is_comment_require','=',False)]}">
                                                    <group>
                                                        <field name="comment_field_type" colspan="1"/>
                                                        <group attrs="{'invisible':[('comment_field_type','!=','char'),('comment_field_type','!=','text')]}">
                                                            <field 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>
                                            <newline/>
                                            <group attrs="{'invisible':[('type','!=','matrix_of_choices_only_one_ans'),('type','!=','rating_scale')]}">
                                                <field name="comment_column"/>
                                                <group colspan="2" attrs="{'invisible':[('comment_column','!=',True)]}">
                                                    <field name="column_name" colspan="2"/>
                                                </group>
                                            </group>
                                            <newline/>
                                            <group attrs="{'invisible':[('type','!=','single_textbox'), ('type','!=','multiple_textboxes')]}">
                                                <separator string="Validation" colspan="4"/>
                                                <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>
                                            <newline/>
                                            <group attrs="{'invisible':[('type','!=','multiple_choice_only_one_ans'), ('type','!=','multiple_choice_multiple_ans'),('type','!=','matrix_of_choices_only_one_ans'),('type','!=','matrix_of_choices_only_multi_ans'),('type','!=','matrix_of_drop_down_menus'),('type','!=','rating_scale'),('type','!=','multiple_textboxes'),('type','!=','numerical_textboxes'),('type','!=','date'),('type','!=','date_and_time'),('type','!=','single_textbox'),('type','!=','comment'),('type','!=','multiple_textboxes_diff_type')]}">
                                                <separator string="Required Answer" colspan="4"/>
                                                <newline/>
                                                <field name="is_require_answer"/>
                                                <group col="6" colspan="4" attrs="{'invisible':[('is_require_answer','=',False)]}">
                                                    <group colspan="4" attrs="{'invisible':[('type','!=','multiple_choice_multiple_ans'),('type','!=','matrix_of_choices_only_one_ans'),('type','!=','matrix_of_choices_only_multi_ans'),('type','!=','matrix_of_drop_down_menus'),('type','!=','rating_scale'),('type','!=','multiple_textboxes'),('type','!=','numerical_textboxes'),('type','!=','date'),('type','!=','date_and_time'),('type','!=','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','!=','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','!=','rating_scale')]}">
                                                        <field name="rating_allow_one_column_require"/>
                                                    </group>
                                                </group>
                                            </group>
                                            <newline/>
                                            <group attrs="{'invisible':[('type','!=','descriptive_text')]}">
                                                <separator string="Descriptive Text" colspan="4"/>
                                                <field name="descriptive_text" colspan="4" nolabel="1"/>
                                            </group>
                                        </page>
                                    </notebook>
                                </group>
                            </form>
                            <tree string="Survey Question">
                                <field name="sequence" string="Seq"/>
                                <field name="question"/>
                                <field name="answer_choice_ids"/>
                            </tree>
                            </field>
                        </group>
                    </sheet>
                </form>
            </field>
        </record>


        <record model="ir.ui.view" id="survey_page_tree">
            <field name="name">survey_page_tree</field>
            <field name="model">survey.page</field>
            <field name="arch" type="xml">
                <tree string="Survey Page">
                    <field name="sequence" string="Seq"/>
                    <field name="title"/>
                    <field name="survey_id"/>
                    <field name="question_ids" string="#Questions"/>
                </tree>
            </field>
        </record>

        <record id="view_survey_page_filter" model="ir.ui.view">
            <field name="name">survey.page.list.select</field>
            <field name="model">survey.page</field>
            <field name="arch" type="xml">
                <search string="Search Survey Page">
                    <field name="title" string="Page"/>
                    <field name="survey_id"/>
                    <group expand="0" string="Group By...">
                        <filter string="Survey" icon="terp-stock_align_left_24" domain="[]"  context="{'group_by':'survey_id'}"/>
                    </group>
                </search>
            </field>
        </record>

        <record model="ir.actions.act_window" id="action_survey_page_form">
            <field name="name">Survey Pages</field>
            <field name="res_model">survey.page</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="view_id" ref="survey_page_tree"></field>
        </record>

        <menuitem name="Survey Pages" id="menu_survey_page_form1"
            action="action_survey_page_form" parent="menu_surveys"
            groups="base.group_no_one"/>

        <record model="ir.ui.view" id="survey_page_wizard_test1">
            <field name="name">survey_page_wizard_test</field>
            <field name="model">survey.page</field>
            <field name="priority">20</field>
            <field name="arch" type="xml">
                <form string="Survey Pages">
                    <field name="title" colspan="4"/>
                    <field name="sequence"/>
                    <separator string="Description" colspan="4"/>
                    <field name="note" colspan="4" nolabel="1"/>
                      <group colspan="4">
                          <label string="" colspan="3"/>
                        <button name="survey_save"  string="Ok" type="object" icon="gtk-go-forward"/>
                    </group>
                </form>
            </field>
        </record>

        <!--
            Survey Question
        -->

        <record model="ir.ui.view" id="survey_question_form">
            <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="page_id"/>
                    <field name="sequence"/>
                    <field name="tot_resp"/>
                    <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"/>
                    <notebook colspan="4">
                        <page string="Options">
                            <group attrs="{'invisible':[('type','!=','multiple_textboxes_diff_type'),('type','!=','multiple_choice_only_one_ans'), ('type','!=','multiple_choice_multiple_ans'),('type','!=','matrix_of_choices_only_one_ans'),('type','!=','matrix_of_choices_only_multi_ans'),('type','!=','matrix_of_drop_down_menus'),('type','!=','rating_scale'),('type','!=','multiple_textboxes'),('type','!=','numerical_textboxes'),('type','!=','date'),('type','!=','date_and_time'),('type','!=','table')]}">
                              <separator string="Answer" colspan="4"/>
                               <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','!=','matrix_of_choices_only_multi_ans'),('type','!=','matrix_of_choices_only_one_ans'),('type','!=','matrix_of_drop_down_menus'),('type','!=','rating_scale'),('type','!=','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','!=','table')]}">
                                       <field name="no_of_rows"/>
                                    </group>
                               </group>
                            </group>
                            <newline/>
                            <group  attrs="{'invisible':[('type','!=','multiple_choice_only_one_ans'), ('type','!=','multiple_choice_multiple_ans'), ('type','!=','matrix_of_choices_only_multi_ans'),('type','!=','matrix_of_choices_only_one_ans'),('type','!=','matrix_of_drop_down_menus'),('type','!=','rating_scale')]}">
                                <separator string="Comment Field" colspan="4"/>
                                <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>
                            <newline/>
                            <group attrs="{'invisible':[('type','!=','matrix_of_choices_only_one_ans'),('type','!=','rating_scale')]}">
                                <field name="comment_column"/>
                                <group colspan="2" attrs="{'invisible':[('comment_column','!=',True)]}">
                                    <field name="column_name" colspan="2"/>
                                </group>
                            </group>
                            <newline/>
                            <group attrs="{'invisible':[('type','!=','single_textbox'), ('type','!=','multiple_textboxes')]}">
                                <separator string="Validation" colspan="4"/>
                                <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>
                            <newline/>
                            <group attrs="{'invisible':[('type','!=','multiple_choice_only_one_ans'), ('type','!=','multiple_choice_multiple_ans'),('type','!=','matrix_of_choices_only_one_ans'),('type','!=','matrix_of_choices_only_multi_ans'),('type','!=','matrix_of_drop_down_menus'),('type','!=','rating_scale'),('type','!=','multiple_textboxes'),('type','!=','numerical_textboxes'),('type','!=','date'),('type','!=','date_and_time'),('type','!=','single_textbox'),('type','!=','comment'),('type','!=','multiple_textboxes_diff_type')]}">
                                <separator string="Required Answer" colspan="4"/>
                                <newline/>
                                <field name="is_require_answer"/>
                                <group col="6" colspan="4" attrs="{'invisible':[('is_require_answer','=',False)]}">
                                    <group colspan="4" attrs="{'invisible':[('type','!=','multiple_choice_multiple_ans'),('type','!=','matrix_of_choices_only_one_ans'),('type','!=','matrix_of_choices_only_multi_ans'),('type','!=','matrix_of_drop_down_menus'),('type','!=','rating_scale'),('type','!=','multiple_textboxes'),('type','!=','numerical_textboxes'),('type','!=','date'),('type','!=','date_and_time'),('type','!=','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','!=','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','!=','rating_scale')]}">
                                        <field name="rating_allow_one_column_require"/>
                                    </group>
                                </group>
                            </group>
                            <newline/>
                            <group attrs="{'invisible':[('type','!=','descriptive_text')]}">
                                <separator string="Descriptive Text" colspan="4"/>
                                <field name="descriptive_text" colspan="4" nolabel="1"/>
                            </group>
                        </page>
                    </notebook>
                </form>
            </field>
        </record>

        <record model="ir.ui.view" id="survey_question_tree">
            <field name="name">survey_question_tree</field>
            <field name="model">survey.question</field>
            <field name="arch" type="xml">
                <tree string="Survey Question">
                    <field name="sequence" string="Seq"/>
                    <field name="question"/>
                    <field name="page_id"/>
                    <field name="survey"/>
                    <field name="type"/>
                </tree>
            </field>
        </record>

        <record id="survey_question_search" model="ir.ui.view">
            <field name="name">survey_question_search</field>
            <field name="model">survey.question</field>
            <field name="arch" type="xml">
                <search string="Search Question">
                    <field name="question" string="Question"/>
                    <field name="survey"/>
                    <field name="type"/>
                    <field name="page_id"/>
                    <group expand="0" string="Group By...">
                        <filter string="Page" icon="terp-stock_align_left_24" domain="[]"  context="{'group_by':'page_id'}"/>
                    </group>
               </search>
            </field>
        </record>

        <record model="ir.actions.act_window" id="action_survey_question_form">
            <field name="name">Survey Questions</field>
            <field name="res_model">survey.question</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="view_id" ref="survey_question_tree"></field>
             <field name="search_view_id" ref="survey_question_search"/>
        </record>

        <record model="ir.ui.view" id="survey_question_wizard_test">
            <field name="name">survey_question_wizard_test</field>
            <field name="model">survey.question</field>
            <field name="priority">20</field>
            <field name="arch" type="xml">
                <form string="Survey Question">
                    <field name="question" colspan="4"/>
                    <field name="page_id"/>
                    <field name="sequence"/>
                    <field name="tot_resp"/>
                    <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"/>
                    <notebook colspan="4">
                        <page string="Options">
                            <group attrs="{'invisible':[('type','!=','multiple_textboxes_diff_type'),('type','!=','multiple_choice_only_one_ans'), ('type','!=','multiple_choice_multiple_ans'),('type','!=','matrix_of_choices_only_one_ans'),('type','!=','matrix_of_choices_only_multi_ans'),('type','!=','matrix_of_drop_down_menus'),('type','!=','rating_scale'),('type','!=','multiple_textboxes'),('type','!=','numerical_textboxes'),('type','!=','date'),('type','!=','date_and_time'),('type','!=','table')]}">
                              <separator string="Answer" colspan="4"/>
                               <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','!=','matrix_of_choices_only_multi_ans'),('type','!=','matrix_of_choices_only_one_ans'),('type','!=','matrix_of_drop_down_menus'),('type','!=','rating_scale'),('type','!=','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','!=','table')]}">
                                       <field name="no_of_rows"/>
                                    </group>
                               </group>
                            </group>
                            <newline/>
                            <group  attrs="{'invisible':[('type','!=','multiple_choice_only_one_ans'), ('type','!=','multiple_choice_multiple_ans'), ('type','!=','matrix_of_choices_only_multi_ans'),('type','!=','matrix_of_choices_only_one_ans'),('type','!=','matrix_of_drop_down_menus'),('type','!=','rating_scale')]}">
                                <separator string="Comment Field" colspan="4"/>
                                <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>
                            <newline/>
                            <group attrs="{'invisible':[('type','!=','matrix_of_choices_only_one_ans'),('type','!=','rating_scale')]}">
                                <field name="comment_column"/>
                                <group colspan="2" attrs="{'invisible':[('comment_column','!=',True)]}">
                                    <field name="column_name" colspan="2"/>
                                </group>
                            </group>
                            <newline/>
                            <group attrs="{'invisible':[('type','!=','single_textbox'), ('type','!=','multiple_textboxes')]}">
                                <separator string="Validation" colspan="4"/>
                                <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>
                            <newline/>
                            <group attrs="{'invisible':[('type','!=','multiple_choice_only_one_ans'), ('type','!=','multiple_choice_multiple_ans'),('type','!=','matrix_of_choices_only_one_ans'),('type','!=','matrix_of_choices_only_multi_ans'),('type','!=','matrix_of_drop_down_menus'),('type','!=','rating_scale'),('type','!=','multiple_textboxes'),('type','!=','numerical_textboxes'),('type','!=','date'),('type','!=','date_and_time'),('type','!=','single_textbox'),('type','!=','comment'),('type','!=','multiple_textboxes_diff_type')]}">
                                <separator string="Required Answer" colspan="4"/>
                                <newline/>
                                <field name="is_require_answer"/>
                                <group col="6" colspan="4" attrs="{'invisible':[('is_require_answer','=',False)]}">
                                    <group colspan="4" attrs="{'invisible':[('type','!=','multiple_choice_multiple_ans'),('type','!=','matrix_of_choices_only_one_ans'),('type','!=','matrix_of_choices_only_multi_ans'),('type','!=','matrix_of_drop_down_menus'),('type','!=','rating_scale'),('type','!=','multiple_textboxes'),('type','!=','numerical_textboxes'),('type','!=','date'),('type','!=','date_and_time'),('type','!=','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','!=','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','!=','rating_scale')]}">
                                        <field name="rating_allow_one_column_require"/>
                                    </group>
                                </group>
                            </group>
                            <newline/>
                            <group attrs="{'invisible':[('type','!=','descriptive_text')]}">
                                <separator string="Descriptive Text" colspan="4"/>
                                <field name="descriptive_text" colspan="4" nolabel="1"/>
                            </group>
                        </page>
                    </notebook>
                      <group colspan="4">
                          <label string="" colspan="3"/>
                        <button name="survey_save"  string="Ok" type="object" icon="gtk-go-forward"/>
                    </group>
                </form>
            </field>
        </record>

        <!--
            Survey Answer
        -->

        <record model ="ir.ui.view" id="survey_answer_form">
            <field name="name">survey_answer_form</field>
            <field name="model">survey.answer</field>
            <field name="arch" type="xml">
                <form string="Survey Answer">
                    <field name="answer" colspan="4"/>
                    <field name="sequence"/>
                    <field name="in_visible_answer_type" invisible="1"/>
                       <group colspan="4" attrs="{'invisible':[('in_visible_answer_type','=',True)]}">
                        <field name="type" colspan="2"/>
                        <group colspan="4" attrs="{'invisible':[('type','!=','selection')]}">
                            <separator string="Menu Choices (each choice on separate by lines)" colspan="4"/>
                            <field name="menu_choice" colspan="4" nolabel="1"/>
                        </group>
                    </group>
                </form>
            </field>
        </record>


        <record model="ir.ui.view" id= "survey_answer_tree">
            <field name="name">survey_answer_tree</field>
            <field name="model">survey.answer</field>
            <field name="arch" type="xml">
                <tree editable="bottom" string="Survey Answer">
                    <field name="sequence" string="Seq"/>
                    <field name="answer"/>
                    <field name="type"/>
                </tree>
            </field>
        </record>

        <!--
            Survey Response Line
        -->

        <record model ="ir.ui.view" id= "survey_response_line_form">
            <field name="name">survey_response_line_form</field>
            <field name="model">survey.response.line</field>
            <field name="arch" type="xml">
                <form string="Survey Answer">
                    <field name="question_id"/>
                    <field name="date_create"/>
                    <notebook colspan="4">
                        <page string="Answer">
                            <field name="response_answer_ids" colspan="4" nolabel="1"/>
                            <group col="5" colspan="4">
                                <field name="state"/>
                            </group>
                        </page>
                        <page string="Single Textboxes">
                            <field name="single_text" colspan="4"/>
                        </page>
                        <page string="Comment">
                            <separator string="Description" colspan="4"/>
                            <field name="comment" nolabel="1" colspan="4"/>
                        </page>
                        <page string="Table Answer">
                            <field name="response_table_ids" colspan="4" nolabel="1">
                            <form string="Table">
                                <field name="column_id"/>
                                <field name="name"/>
                                <field name="value"/>
                            </form>
                            <tree string="Table">
                                <field name="column_id"/>
                                <field name="name"/>
                                <field name="value"/>
                            </tree>
                            </field>
                        </page>
                    </notebook>
                </form>
            </field>
        </record>

        <record model="ir.ui.view" id="survey_response_line_tree">
            <field name="name">survey_response_line_tree</field>
            <field name="model">survey.response.line</field>
            <field name="arch" type="xml">
                <tree string="Survey Answer Line">
                    <field name="page_id"/>
                    <field name="question_id"/>
                    <field name="date_create"/>
                    <field name="state"/>
                </tree>
            </field>
        </record>

        <!--
            Survey Response
        -->

        <record model="ir.ui.view" id="survey_response_form">
            <field name="name">survey_response_form</field>
            <field name="model">survey.response</field>
            <field name="arch" type="xml">
                <form string="Survey Answer">
                    <field name="survey_id"/>
                    <field name="date_create"/>
                    <field name="user_id"/>
                    <field name="response_type"/>
                    <field name="question_ids" nolabel="1" colspan="4" />
                    <field name="state"/>
                </form>
            </field>
        </record>

        <record model="ir.ui.view" id="survey_response_tree">
            <field name="name">survey_response_tree</field>
            <field name="model">survey.response</field>
            <field name="arch" type="xml">
                <tree string="Survey Answer">
                    <field name="survey_id"/>
                    <field name="date_create"/>
                    <field name="user_id"/>
                    <field name="response_type"/>
                    <field name="state"/>
                </tree>
            </field>
        </record>

        <!--
            Survey Response Answer
        -->

        <record model="ir.ui.view" id="survey_response_answer_form">
            <field name="name">survey_response_answer_form</field>
            <field name="model">survey.response.answer</field>
            <field name="arch" type="xml">
                <form string="Survey Answer">
                    <group colspan="4">
                        <field name="answer_id"/>
                        <field name="answer" />
                    </group>
                    <field name="value_choice"/>
                    <label string="(Use Only Question Type is matrix_of_drop_down_menus)" align="0.0"/>
                    <group colspan="4" col="4">
                        <field name="comment_field"/>
                        <field name="column_id"/>
                    </group>
                </form>
            </field>
        </record>

        <record model="ir.ui.view" id="survey_response_answer_tree">
            <field name="name">survey_response_answer_tree</field>
            <field name="model">survey.response.answer</field>
            <field name="arch" type="xml">
                <tree editable="top" string="Survey Answer">
                    <field name="answer_id"/>
                    <field name="answer" />
                    <field name="value_choice" />
                    <field name="column_id"/>
                    <field name="comment_field"/>
                </tree>
            </field>
        </record>

        <!--
            Survey Question Column Heading
    -->

        <record model="ir.ui.view" id="survey_question_column_heading_form">
            <field name="name">survey_question_column_heading_form</field>
            <field name="model">survey.question.column.heading</field>
            <field name="arch" type="xml">
                <form string="Column Heading">
                    <field name="title"/>
                    <field name="in_visible_rating_weight" invisible="1"/>
                    <field name="in_visible_menu_choice" invisible="1"/>
                    <group colspan="4" attrs="{'invisible':[('in_visible_rating_weight','!=',False)]}">
                        <field name="rating_weight"/>
                        <label align="0.0" string="Use if question type is rating_scale" />
                    </group>
                    <group colspan="4" attrs="{'invisible':[('in_visible_menu_choice','!=',False)]}">
                        <separator string="Menu Choices (each choice on separate lines)" colspan="4"/>
                        <field name="menu_choice" nolabel="1" colspan="4"/>
                    </group>
                </form>
            </field>
        </record>

        <record model="ir.ui.view" id="survey_question_column_heading_tree">
            <field name="name">survey_question_column_heading_tree</field>
            <field name="model">survey.question.column.heading</field>
            <field name="arch" type="xml">
                <tree editable="bottom" string="Column Heading">
                    <field name="title"/>
                </tree>
            </field>
        </record>

        <!--
            Survey Request
        -->

        <record model="ir.ui.view" id="survey_request_form">
            <field name="name">survey_request_form</field>
            <field name="model">survey.request</field>
            <field name="arch" type="xml">
                <form string="Request" version="7.0">
                <header>
                    <button name="survey_req_draft" string="Set to Draft" states="cancel,done" type="object"/>
                    <button name="survey_req_waiting_answer" string="Waiting Answer" states="draft" type="object" class="oe_highlight"/>
                    <button name="survey_req_done" string="Done" states="waiting_answer" type="object" class="oe_highlight"/>
                    <button name="survey_req_cancel" string="Cancel Request" states="waiting_answer" type="object"/>
                    <field name="state" widget="statusbar" statusbar_visible="draft,waiting_answer"/>
                </header>
                <sheet string="Survey Request">
                    <group class="oe_header">
                    <field name="date_deadline"/>
                    <field name="survey_id"/>
                    <field name="user_id" on_change="on_change_user(user_id)"/>
                    <field name="email"/>
                    <field name="response" readonly="1" attrs="{'invisible':[('response','=',False)]}"/>
                    </group>
                    </sheet>
                </form>
            </field>
        </record>

        <record model="ir.ui.view" id="survey_request_tree">
            <field name="name">survey_request_tree</field>
            <field name="model">survey.request</field>
            <field name="arch" type="xml">
                <tree string="Evaluation Plan Phase" colors="red:date_deadline&lt;current_date">
                    <field name="date_deadline"/>
                    <field name="user_id"/>
                    <field name="email"/>
                    <field name="survey_id"/>
                    <field name="response" />
                    <field name="state" />
                </tree>
            </field>
        </record>

       <record id="survey_request_search" model="ir.ui.view">
            <field name="name">survey_request_search</field>
            <field name="model">survey.request</field>
            <field name="arch" type="xml">
                <search string="Search Survey">
                    <field name="email" string="Survey"/>
                    <filter icon="terp-gtk-media-pause" string="Waiting Answer" domain="[('state','=','waiting_answer')]"/>
                    <separator/>
                    <filter icon="terp-emblem-important" string="Late" domain="[('date_deadline','&lt;',current_date)]"/>
                    <separator/>
                    <filter string="My Survey(s)" icon="terp-personal" domain="[('user_id','=',uid)]"/>
                    <field name="survey_id" widget="selection"/>
                    <field name="user_id"/>
                    <group expand="0" string="Group By...">
                        <filter string="User" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/>
                        <filter string="Survey" icon="terp-stock_align_left_24" domain="[]"  context="{'group_by':'survey_id'}"/>
                        <filter string="Status" icon="terp-stock_effects-object-colorize" domain="[]"  context="{'group_by':'state'}"/>
                    </group>
               </search>
            </field>
        </record>

        <record model="ir.actions.act_window" id="action_survey_request_tree">
            <field name="name">Survey Requests</field>
            <field name="res_model">survey.request</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="domain">[('user_id','=',uid)]</field>
            <field name="view_id" ref="survey_request_tree"></field>
            <field name="search_view_id" ref="survey_request_search"/>
        </record>

        <menuitem name="Survey Requests" id="menu_survey_type_form1"
            action="action_survey_request_tree" parent="menu_surveys"
            groups="base.group_tool_manager" sequence="3"/>

        <!--
            Survey Type
        -->

        <record model="ir.ui.view" id="survey_type_form">
            <field name="name">survey_type_form</field>
            <field name="model">survey.type</field>
            <field name="arch" type="xml">
                <form string="Survey Type">
                    <field name="name"/>
                    <field name="code"/>
                </form>
            </field>
        </record>

        <record model="ir.ui.view" id="survey_type_tree">
            <field name="name">survey_type_tree</field>
            <field name="model">survey.type</field>
            <field name="arch" type="xml">
                <tree string="Survey Type">
                    <field name="name"/>
                    <field name="code"/>
                </tree>
            </field>
        </record>

        <record model="ir.actions.act_window" id="action_survey_type_form">
            <field name="name">Survey Type</field>
            <field name="res_model">survey.type</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="view_id" ref="survey_type_tree"></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"/>

        <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"/>


        <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.answer"
            src_model="survey.question"/>

        <act_window
            context="{'search_default_survey_id': active_id, 'default_survey_id': active_id}"
            id="act_survey_request"
            name="Survey Requests"
            res_model="survey.request"
            src_model="survey"/>

    </data>
</openerp>
