<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <!-- Delivery Carriers -->
        <menuitem id="menu_delivery" name="Delivery" parent="stock.menu_stock_configuration" sequence="4"/>

        <record id="view_delivery_carrier_tree" model="ir.ui.view">
            <field name="name">delivery.carrier.tree</field>
            <field name="model">delivery.carrier</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Carrier">
                    <field name="name"/>
                    <field name="partner_id"/>
                    <field name="price" invisible="'order_id' not in context"/>
                </tree>
            </field>
        </record>
        <record id="view_delivery_carrier_form" model="ir.ui.view">
            <field name="name">delivery.carrier.form</field>
            <field name="model">delivery.carrier</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Carrier">
                    <field name="name" select="1"/>
                    <field name="active" select="1"/>
                    <field name="partner_id" select="1"/>
                    <field name="product_id" select="1"/>
                </form>
            </field>
        </record>
        <record id="action_delivery_carrier_form" model="ir.actions.act_window">
            <field name="name">Delivery Method</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">delivery.carrier</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
        </record>
        <menuitem action="action_delivery_carrier_form" id="menu_action_delivery_carrier_form" parent="menu_delivery" groups="base.group_system"/>

        <!-- Delivery Grids -->
        <record id="view_delivery_grid_tree" model="ir.ui.view">
            <field name="name">delivery.grid.tree</field>
            <field name="model">delivery.grid</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Delivery grids">
                    <field name="sequence"/>
                    <field name="carrier_id"/>
                    <field name="name"/>
                </tree>
            </field>
        </record>

        <record id="view_delivery_grid_form" model="ir.ui.view">
            <field name="name">delivery.grid.form</field>
            <field name="model">delivery.grid</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Delivery grids">
                    <field name="name" select="1"/>
                    <field name="active" select="1"/>
                    <field name="carrier_id" select="1"/>
                    <field name="sequence" groups="base.group_extended" select="1"/>
                    <notebook colspan="4">
                        <page string="Grid definition">
                            <field colspan="4" name="line_ids" nolabel="1" select="1"/>
                        </page>
                        <page string="Destination">
                            <separator colspan="4" string="Countries"/>
                            <field colspan="4" name="country_ids" nolabel="1"/>
                            <separator colspan="4" string="States"/>
                            <field colspan="4" name="state_ids" nolabel="1"/>
                            <field name="zip_from"/>
                            <field name="zip_to"/>
                        </page>
                    </notebook>
                </form>
            </field>
        </record>
        <record id="action_delivery_grid_form" model="ir.actions.act_window">
            <field name="name">Delivery Pricelist</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">delivery.grid</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
        </record>
        <menuitem action="action_delivery_grid_form" id="menu_action_delivery_grid_form" parent="menu_delivery"/>

        <record id="view_delivery_grid_line_form" model="ir.ui.view">
            <field name="name">delivery.grid.line.form</field>
            <field name="model">delivery.grid.line</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Grid Lines">
                    <field colspan="4" name="name" select="1"/>
                    <field name="type" string="Condition"/>
                    <field name="operator" nolabel="1"/>
                    <field name="max_value" nolabel="1"/>
                    <field name="list_price"/>
                    <field name="standard_price" groups="base.group_extended"/>
                    <field name="price_type"  />
                    <field name="variable_factor" attrs="{'invisible':[('price_type','=','fixed')]}"/>
                </form>
            </field>
        </record>
        <record id="view_delivery_grid_line_tree" model="ir.ui.view">
            <field name="name">delivery.grid.line.tree</field>
            <field name="model">delivery.grid.line</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Grid Lines">
                    <field name="name"/>
                    <field name="type"/>
                    <field name="operator"/>
                    <field name="max_value"/>
                    <field name="list_price"/>
                    <field name="standard_price" groups="base.group_extended"/>
                </tree>
            </field>
        </record>

        <record id="view_order_withcarrier_form" model="ir.ui.view">
            <field name="name">delivery.sale.order_withcarrier.form.view</field>
            <field name="type">form</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_order_form"/>
            <field name="arch" type="xml">
                <group name="logistic" position="inside">
                    <field name="id" invisible="True"/>
                    <field name="carrier_id" context="{'order_id':active_id}"/>
                </group>
            </field>
        </record>

        <record id="view_picking_withcarrier_out_form" model="ir.ui.view">
            <field name="name">delivery.stock.picking_withcarrier.out.form.view</field>
            <field name="type">form</field>
            <field name="model">stock.picking</field>
            <field name="inherit_id" ref="stock.view_picking_out_form"/>
            <field name="arch" type="xml">
                <field name="address_id" position="after">
                    <field name="carrier_id"/>
                    <field name="carrier_tracking_ref" groups="base.group_extended"/>
                    <field name="number_of_packages" groups="base.group_extended"/>
                    <field name="weight"/>
                    <field name="weight_net"/>
                </field>
            </field>
        </record>

        <record id="view_picking_withweight_in_form" model="ir.ui.view">
            <field name="name">stock.picking_withweight.in.form.view</field>
            <field name="type">form</field>
            <field name="model">stock.picking</field>
            <field name="inherit_id" ref="stock.view_picking_in_form"/>
            <field name="arch" type="xml">
                <field name="type" position="after">
                    <field name="weight"/>
                    <field name="weight_net"/>
                </field>
            </field>
        </record>

        <record id="view_picking_withweight_internal_form" model="ir.ui.view">
            <field name="name">stock.picking_withweight.internal.form.view</field>
            <field name="type">form</field>
            <field name="model">stock.picking</field>
            <field name="inherit_id" ref="stock.view_picking_form"/>
            <field name="arch" type="xml">
                <field name="type" position="after">
                    <field name="weight"/>
                    <field name="weight_net"/>
                </field>
            </field>
        </record>

        <record id="view_picking_withcarrier_delivery_form" model="ir.ui.view">
            <field name="name">delivery.stock.picking_withcarrier.delivery.form.view</field>
            <field name="type">form</field>
            <field name="model">stock.picking</field>
            <field name="inherit_id" ref="stock.view_picking_delivery_form"/>
            <field name="arch" type="xml">
                <field name="address_id" position="after">
                    <field name="carrier_id"/>
                    <field name="carrier_tracking_ref" groups="base.group_extended"/>
                    <field name="number_of_packages" groups="base.group_extended"/>
                    <field name="weight"/>
                    <field name="weight_net"/>
                </field>
            </field>
        </record>

        <record id="action_picking_tree4" model="ir.actions.act_window">
            <field name="name">Picking to be invoiced</field>
            <field name="res_model">stock.picking</field>
            <field name="type">ir.actions.act_window</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="domain">[('invoice_state','=','2binvoiced'),('state','=','done'),('type','=','out')]</field>
            <field name="filter" eval="True"/>
            <field name="context">{'contact_display': 'partner'}</field>
            <field name="search_view_id" ref="stock.view_picking_out_search"/>
        </record>

        <record id="view_picking_withcarrier_out_move_form" model="ir.ui.view">
            <field name="name">delivery.stock.picking_withcarrier.out.move.form.view</field>
            <field name="type">form</field>
            <field name="model">stock.picking</field>
            <field name="inherit_id" ref="stock.view_picking_out_form"/>
            <field name="arch" type="xml">
                <xpath expr="/form/notebook/page/field[@name='move_lines']/tree/field[@name='product_uom']" position="after">
                    <field name="weight"/>
                    <field name="weight_net"/>
                </xpath>
            </field>
        </record>

        <record id="view_picking_withweight_in_move_form" model="ir.ui.view">
            <field name="name">stock.picking_withweight.in.move.form.view</field>
            <field name="type">form</field>
            <field name="model">stock.picking</field>
            <field name="inherit_id" ref="stock.view_picking_in_form"/>
            <field name="arch" type="xml">
                <xpath expr="/form/notebook/page/field[@name='move_lines']/tree/field[@name='product_uom']" position="after">
                    <field name="weight"/>
                    <field name="weight_net"/>
                </xpath>
            </field>
        </record>

        <record id="view_picking_withweight_internal_move_form" model="ir.ui.view">
            <field name="name">stock.picking_withweight.internal.move.form.view</field>
            <field name="type">form</field>
            <field name="model">stock.picking</field>
            <field name="inherit_id" ref="stock.view_picking_form"/>
            <field name="arch" type="xml">
                <xpath expr="/form/notebook/page/field[@name='move_lines']/tree/field[@name='product_uom']" position="after">
                    <field name="weight"/>
                    <field name="weight_net"/>
                </xpath>
            </field>
        </record>

        <record id="view_picking_withcarrier_delivery_move_form" model="ir.ui.view">
            <field name="name">delivery.stock.picking_withcarrier.delivery.move.form.view</field>
            <field name="type">form</field>
            <field name="model">stock.picking</field>
            <field name="inherit_id" ref="stock.view_picking_delivery_form"/>
            <field name="arch" type="xml">
                <xpath expr="/form/notebook/page/field[@name='move_lines']/tree/field[@name='product_uom']" position="after">
                    <field name="weight"/>
                    <field name="weight_net"/>
                </xpath>
            </field>
        </record>

        <record id="view_move_withweight_form" model="ir.ui.view">
            <field name="name">stock.move.form.weight</field>
            <field name="type">form</field>
            <field name="model">stock.move</field>
            <field name="inherit_id" ref="stock.view_move_form"/>
            <field name="arch" type="xml">
                <field name="product_uom" position="after">
                    <field name="weight"/>
                    <field name="weight_net"/>
                </field>
            </field>
        </record>

        <record id="view_move_reception_picking_withweight_form" model="ir.ui.view">
            <field name="name">stock.move.reception.packing.form.weight</field>
            <field name="type">form</field>
            <field name="model">stock.move</field>
            <field name="inherit_id" ref="stock.view_move_form_reception_picking"/>
            <field name="arch" type="xml">
                <field name="product_uom" position="after">
                    <field name="weight"/>
                    <field name="weight_net"/>
                </field>
            </field>
        </record>

        <record model="ir.ui.view" id="edit_project_multicompany">
            <field name="name">sale.order.multicompany</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_order_form"/>
            <field name="arch" type="xml">
                    <xpath expr="/form/notebook/page[@string='Sales Order']/group[1]/button[@name='button_dummy']" position="after">
                         <button name="%(action_delivery_cost)d" states="draft" string="Delivery Costs" type="action" icon="gtk-add" context="{'order_id':id}"/>                    
                    </xpath>
            </field>
        </record>

    </data>
</openerp>
