<?xml version="1.0"?>
<openerp>
    <data>
    <!--Partner Grade -->


    <record id="view_partner_grade_tree" model="ir.ui.view">
        <field name="name">res.partner.grade.tree</field>
        <field name="model">res.partner.grade</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Partner Grade">
                <field name="sequence" invisible="1"/>
                <field name="name"/>
            </tree>
        </field>
    </record>
    <record id="view_partner_grade_form" model="ir.ui.view">
        <field name="name">res.partner.grade.form</field>
        <field name="model">res.partner.grade</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="Partner Grade">
                <group col="6" colspan="4">
                    <field name="name" select="1"/>
                    <field name="sequence"/>
                    <field name="active"/>
                </group>
            </form>
        </field>
    </record>
    <record id="res_partner_grade_action" model="ir.actions.act_window">
        <field name="name">Partner Grade</field>
        <field name="res_model">res.partner.grade</field>
        <field name="view_type">form</field>
    </record>
    <menuitem action="res_partner_grade_action" id="menu_res_partner_grade_action"
        groups="base.group_extended"
        parent="base.menu_crm_config_lead" />

    <!-- Partner form -->
    <record id="view_res_partner_filter_assign_tree" model="ir.ui.view">
        <field name="name">res.partner.geo.inherit.tree</field>
        <field name="model">res.partner</field>
        <field name="type">tree</field>
        <field name="inherit_id" ref="base.view_partner_tree"/>
        <field name="arch" type="xml">
            <field name="user_id" position="after">
                <field name="grade_id"/>
            </field>
        </field>
    </record>

    <record id="view_res_partner_filter_assign" model="ir.ui.view">
        <field name="name">res.partner.geo.inherit.search</field>
        <field name="model">res.partner</field>
        <field name="type">search</field>
        <field name="inherit_id" ref="base.view_res_partner_filter"/>
        <field name="arch" type="xml">
            <field name="category_id" position="after">
                <field name="grade_id"/>
            </field>
        </field>
    </record>

    <record id="view_crm_partner_geo_form" model="ir.ui.view">
        <field name="name">res.partner.geo.inherit</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">
            <xpath expr="//notebook[last()]" position="inside">
                <page string="Geo Localization">
                    <field name="grade_id" widget="selection"/>
                    <newline/>
                    <field name="partner_weight"/>
                    <label string="" colspan="1"/>
                    <button
                        string="Geo Localize"
                        name="geo_localize"
                        icon="gtk-apply"
                        type="object"/>
                    <newline/>
                    <field name="partner_latitude"/>
                    <field name="partner_longitude"/>
                    <field name="date_localization"/>

                    <field name="opportunity_assigned_ids" colspan="4" nolabel="1">
                         <tree string="Assigned Opportunities"  colors="blue:state=='pending';gray:state=='cancel'">
                             <field name="create_date"/>
                             <field name="name"/>
                             <field name="type"/>
                             <field name="stage_id"/>
                             <button name="stage_previous" string="Previous"
                                 states="open,pending" type="object" icon="gtk-go-back" />
                             <button name="stage_next" string="Next"
                                 states="open,pending" type="object"
                                 icon="gtk-go-forward" />
                             <field name="section_id"
                                 invisible="context.get('invisible_section', True)" />
                             <field name="user_id" />
                             <field name="state" />
                             <button name="case_cancel" string="Cancel"
                                 states="draft,open,pending" type="object"
                                 icon="gtk-cancel" />
                             <button name="case_open" string="Open"
                                 states="draft,pending" type="object"
                                 icon="gtk-go-forward" />
                             <button name="case_close" string="Close"
                                 states="open,draft,pending" type="object"
                                 icon="gtk-close" />
                             <button string="Convert to Opportunity"
                                 name="convert_opportunity"
                                 states="draft,open,pending" icon="gtk-index"
                                 type="object" attrs="{'invisible':[('type','=','opportunity')]}" />
                             <button name="case_escalate" string="Escalate"
                                 states="open,draft,pending" type="object"
                                 icon="gtk-go-up" />
                         </tree>
                    </field>
                </page>
            </xpath>
        </field>
    </record>
    </data>
</openerp>
