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

        <wizard
            string="Using a questionnaire"
            model="crm_profiling.questionnaire"
            name="open_questionnaire"
            menu="False"
            id="wizard_open_questionnaire"/>

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

        <menuitem parent="base.menu_crm_config_lead" id="menu_segm_questionnaire"
                  action="open_questionnaires" />

        <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_crm_config_lead" id="menu_segm_answer"
                  action="open_questions" />

<!-- 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="type">tree</field>
        <field name="arch" type="xml">
          <tree string="Questionnaires">
            <field name="name" select="1" colspan="4"/>
            <field name="description" select="1" 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="type">form</field>
        <field name="arch" type="xml">
          <form string="Questionnaires">
            <field name="name" select="1" />
            <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" select="1" 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="type">tree</field>
        <field name="arch" type="xml">
          <tree string="Answers">
            <field name="question_id" select="1"/>
            <field name="name" select="1"/>
          </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="type">form</field>
        <field name="arch" type="xml">
          <form string="Answers">
            <field name="question_id" select="1"/>
            <field name="name" select="1"/>
          </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="type">tree</field>
        <field name="arch" type="xml">
          <tree string="Questions">
            <field name="name" select="1" 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="type">form</field>
        <field name="arch" type="xml">
          <form string="Questions">
            <newline/>
            <field name="name" select="1" />
            <newline/>
            <separator string="Avalaible answers" colspan="4"/>
            <field name="answers_ids" colspan="4" nolabel="1" editable="bottom">
              <tree string="Answers" editable="bottom">
                <field name="name" select="1"/>
              </tree>
              <form string="Answers">
                <field name="name" select="1"/>
              </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="type">form</field>
        <field name="inherit_id" ref="base.view_partner_form"/>
        <field name="arch" type="xml">
            <notebook position="inside">
                <page string="Profiling">
                  <button string="Use a questionnaire"
                      name="%(wizard_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="type">form</field>
        <field name="arch" type="xml">
            <form string="Partner Segmentation">
                <notebook>
                <page string="Segmentation">
                    <separator string="Segmentation Description" colspan="4"/>
                    <field name="name" select="1"/>
                    <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="State of Mind Computation" colspan="4"/>
                    <field name="som_interval"/>
                    <field name="som_interval_max"/>
                    <field name="som_interval_decrease"/>
                    <field name="som_interval_default"/>
                    <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="type">tree</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>
