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

        <record model="ir.ui.view" id="crm_case_form_view_oppor">
            <field name="name">CRM - Opportunities - Quote Inherit</field>
            <field name="model">crm.lead</field>
            <field name="inherit_id" ref="crm.crm_case_form_view_oppor"/>
            <field name="arch" type="xml">
                <data>
                    <xpath expr="/form/header/button[@name='case_mark_lost']" position="after">
                        <button states="done" string="Create Quotation" name="%(action_crm_make_sale)d" type="action"/>
                        <button states="draft,open,pending" string="Convert to Quotation" name="%(action_crm_make_sale)d" type="action" class="oe_highlight"/>
                    </xpath>
                </data>
            </field>
        </record>

        <!-- add needaction_menu_ref to reload quotation needaction when opportunity needaction is reloaded -->
        <record model="ir.actions.act_window" id="crm.crm_case_category_act_oppor11">
            <field name="context">{'stage_type': 'opportunity', 'default_type': 'opportunity', 'default_user_id': uid, 'needaction_menu_ref': 'sale.menu_sale_quotations'}</field>
        </record>

        <record model="ir.ui.view" id="sale_view_inherit123">
            <field name="name">sale.order.inherit</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_order_form"/>
            <field name="arch" type="xml">
                <field name="user_id" position="after">
                    <field name="section_id" widget="selection"/>
                    <field name="categ_ids" widget="many2many_tags"/>
                </field>
            </field>
        </record>

        <record id="view_sales_order_filter_inherit" model="ir.ui.view">
            <field name="name">sale.order.list.select</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_sales_order_filter"/>
            <field name="arch" type="xml">
                <xpath expr="//filter[@name='my_sale_orders_filter']" position="after">
                    <separator/>
                    <filter string="My Sales Team(s)"
                        icon="terp-personal+"
                        domain="[('section_id.user_id','=',uid)]"
                        help="My Sales Team(s)"/>
                </xpath>
                <xpath expr="//field[@name='user_id']" position="after">
                    <field name="section_id" string="Sales Team"/>
                </xpath>
            </field>
        </record>

        <!-- Update account invoice list view!-->
        <record model="ir.ui.view" id="account_invoice_tree">
            <field name="name">Account Invoice</field>
            <field name="model">account.invoice</field>
            <field name="inherit_id" ref="account.invoice_tree"/>
            <field name="arch" type="xml">
                <data>
                    <xpath expr="//field[@name='date_invoice']" position="after">
                        <field name="section_id" invisible="1"/>
                    </xpath>
                </data>
            </field>
        </record>

        <record id="account_invoice_groupby_inherit" model="ir.ui.view">
            <field name="name">account.invoice.groupby</field>
            <field name="model">account.invoice</field>
            <field name="inherit_id" ref="account.view_account_invoice_filter"/>
            <field name="arch" type="xml">
                <xpath expr="//group/filter[@string='Due Date']" position="after">
                    <filter string="Sales Team" domain="[]" context="{'group_by':'section_id'}"/>
                </xpath>
            </field>
        </record>

        <!-- Update account invoice !-->
        <record model="ir.ui.view" id="account_invoice_form">
            <field name="name">Account Invoice</field>
            <field name="model">account.invoice</field>
            <field name="inherit_id" ref="account.invoice_form"/>
            <field name="arch" type="xml">
                <data>
                    <xpath expr="//field[@name='user_id']" position="after">
                        <field name="section_id"/>
                    </xpath>
                </data>
            </field>
        </record>

        <!-- Update user form !-->
        <record model="ir.ui.view" id="res_user_form">
            <field name="name">Users Preferences</field>
            <field name="model">res.users</field>
            <field name="inherit_id" ref="base.view_users_form"/>
            <field name="arch" type="xml">
                <data>
                    <xpath expr="//field[@name='email']" position="after">
                        <field name="default_section_id"/>
                    </xpath>
                </data>
            </field>
        </record>

        <!-- Update Preferences form !-->
        <record id="view_users_form_preferences" model="ir.ui.view">
            <field name="name">res.users.preferences.form</field>
            <field name="model">res.users</field>
            <field name="inherit_id" ref="base.view_users_form_simple_modif"/>
            <field name="arch" type="xml">
            <data>
                    <xpath expr="//field[@name='company_id']" position="after">
                        <field name="default_section_id" readonly="0"/>
                    </xpath>
                </data>
            </field>
        </record>

    </data>
</openerp>
