<?xml version="1.0" ?>
<openerp>
    <data>

        <record model="ir.actions.act_window" id="open_questionnaires">
          <field name="name">Questionnaires</field>
          <field name="res_model">crm_profiling.questionnaire</field>
          <field name="view_type">form</field>
          <field name="view_mode">tree,form</field>
          <field name="help">You can create specific topic-related questionnaires to guide your team(s) in the sales cycle by helping them to ask the right questions. The segmentation tool allows you to automatically assign a partner to a category according to his answers to the different questionnaires.</field>
        </record>

        <menuitem parent="base.menu_base_config" id="menu_segm_questionnaire"
                  action="open_questionnaires" sequence="1"/>

        <record model="ir.actions.act_window" id="open_questions">
          <field name="name">Questions</field>
          <field name="res_model">crm_profiling.question</field>
          <field name="view_type">form</field>
          <field name="view_mode">tree,form</field>
        </record>

        <menuitem parent="base.menu_base_config" id="menu_segm_answer"
                  action="open_questions" sequence="37" groups="base.group_no_one"/>

<!-- Profiling Questionnaire Tree view  -->

    <record model="ir.ui.view" id="view_questionnaire_tree">
        <field name="name">Questionnaires</field>
        <field name="model">crm_profiling.questionnaire</field>
        <field name="arch" type="xml">
          <tree string="Questionnaires">
            <field name="name" colspan="4"/>
            <field name="description" colspan="4"/>
            <field name="questions_ids" colspan="4" nolabel="1"/>
          </tree>
        </field>
    </record>

<!-- Profiling Questionnaire Form view  -->

    <record model="ir.ui.view" id="view_questionnaire_form">
        <field name="name">Questionnaires</field>
        <field name="model">crm_profiling.questionnaire</field>
        <field name="arch" type="xml">
          <form string="Questionnaires">
            <field name="name"/>
            <newline/>
            <separator string="Questions List" colspan="4"/>
            <field name="questions_ids" colspan="4" nolabel="1"/>
            <newline/>
            <separator string="Description" colspan="4"/>
            <field name="description" colspan="4" nolabel="1"/>
          </form>
        </field>
    </record>

<!-- Profiling Answer Tree view  -->

    <record model="ir.ui.view" id="view_answer">
        <field name="name">Answers</field>
        <field name="model">crm_profiling.answer</field>
        <field name="arch" type="xml">
          <tree string="Answers">
            <field name="question_id"/>
            <field name="name"/>
          </tree>
        </field>
    </record>

<!-- Profiling Answer Form view  -->

    <record model="ir.ui.view" id="view_answer_form">
        <field name="name">Answers</field>
        <field name="model">crm_profiling.answer</field>
        <field name="arch" type="xml">
          <form string="Answers">
            <field name="question_id"/>
            <field name="name"/>
          </form>
        </field>
    </record>

<!-- Profiling Questions Tree view  -->

    <record model="ir.ui.view" id="view_question_tree">
        <field name="name">Questions</field>
        <field name="model">crm_profiling.question</field>
        <field name="arch" type="xml">
          <tree string="Questions">
            <field name="name" colspan="4"/>
            <field name="answers_ids" colspan="4" nolabel="1"/>
          </tree>
        </field>
    </record>

<!-- Profiling Questions Form view  -->

    <record model="ir.ui.view" id="view_question_form">
        <field name="name">Questions</field>
        <field name="model">crm_profiling.question</field>
        <field name="arch" type="xml">
          <form string="Questions">
            <newline/>
            <field name="name"/>
            <newline/>
            <separator string="Avalaible Answers" colspan="4"/>
            <field name="answers_ids" colspan="4" nolabel="1">
              <tree string="Answers" editable="bottom">
                <field name="name"/>
              </tree>
              <form string="Answers">
                <field name="name"/>
              </form>
            </field>
          </form>
        </field>
    </record>


    <record model="ir.ui.view" id="view_partner_form">
        <field name="name">res.partner.profile.form</field>
        <field name="model">res.partner</field>
        <field name="inherit_id" ref="base.view_partner_form"/>
        <field name="arch" type="xml">
            <notebook position="inside">
                <page string="Profiling" groups="base.group_user">
                  <button string="Use a questionnaire"
                      name="%(action_open_questionnaire)d" type="action" colspan="1"
                      icon="gtk-justify-fill" />
                  <newline/>
                  <field name="answers_ids" colspan="4" nolabel="1"/>
                </page>
            </notebook>
        </field>
    </record>

<!-- CRM Segmentation Form view  -->

    <record model="ir.ui.view" id="crm.crm_segmentation-view">
        <field name="name">crm.segmentation.form</field>
        <field name="model">crm.segmentation</field>
        <field name="arch" type="xml">
            <form string="Partner Segmentation">
                <notebook>
                <page string="Segmentation">
                    <separator string="Segmentation Description" colspan="4"/>
                    <field name="name"/>
                    <field name="exclusif"/>
                    <newline/>
                    <field name="categ_id" colspan="2"/>
                    <newline/>
                    <field name="description" colspan="4"/>
                    <field name="state"/>
                    <group col="3" colspan="2">
                        <button name="process_start"
                            states="not running" string="Compute Segmentation" type="object"
                            icon="gtk-apply" />
                        <button name="process_stop" states="running"
                            string="Stop Process" type="object" icon="gtk-stop" />
                        <button name="process_continue" states="running"
                            string="Continue Process" type="object" icon="gtk-go-forward" />
                    </group>
                </page>
                <page string="Sales Purchase">
                    <field name="sales_purchase_active"/>
                    <separator string="Segmentation Test" colspan="4"/>
                    <field name="segmentation_line" widget="one2many_list" colspan="4"/>
                </page>
                <page string="Profiling">
                    <field name="profiling_active" colspan="2"/>
                    <separator string="Profiling Options" colspan="4"/>
                    <field name="parent_id" colspan="2"/><newline/>
                    <separator string="Included Answers :" colspan="2" />
                    <separator string="Excluded Answers :" colspan="2"/>
                    <field name="answer_yes" nolabel="1" colspan="2"/>
                    <field name="answer_no" nolabel="1" colspan="2"/>
                </page>
                </notebook>
            </form>
        </field>
    </record>

<!-- CRM Segmentation Tree view  -->

    <record model="ir.ui.view" id="view_partner_crm_segmentation_tree">
        <field name="name">crm.segmentation.tree</field>
        <field name="model">crm.segmentation</field>
        <field name="arch" type="xml">
            <tree string="Partner Segmentations">
                <field name="name"/>
                <field name="description"/>
                <field name="categ_id"/>
            </tree>
        </field>
    </record>

    </data>
</openerp>
