<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">
                    <group colspan="4" col="4" name="general">
                        <field name="name" select="1"/>
                        <field name="active" select="1"/>
                        <field name="partner_id" select="1"/>
                        <field name="product_id" select="1"/>
                        <separator string="Pricing Information" colspan="6"/>
                        <group colspan="2" col="4">
                            <field name="normal_price" select="1" colspan="4"/>
                            <newline/>
                            <field name="free_if_more_than"/>
                            <field name="amount" attrs="{'invisible':[('free_if_more_than','=',False)]}"/>
                        </group>
                        <newline/>
                        <field name="use_detailed_pricelist"/>
                    </group>
                        <field name="pricelist_ids" nolabel="1" attrs="{'invisible':[('use_detailed_pricelist','=',False)]}" mode="tree,form">
                         <tree string="Delivery grids">
                              <field name="sequence"/>
                              <field name="carrier_id"/>
                              <field name="name"/>
                         </tree>
                        <form string="Delivery grids">
                             <field name="name" select="1"/>
                             <field name="active" 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>
                </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>
            <field name="help">Define the delivery methods you are using and their pricing in order to reinvoice the delivery costs when you are doing invoicing based on delivery orders</field>
        </record>

        <record id="action_delivery_carrier_form1" 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">form,tree</field>
            <field name="help">Define the delivery methods you are using and their pricing in order to reinvoice the delivery costs when you are doing invoicing based on delivery orders</field>
        </record>

        <menuitem action="action_delivery_carrier_form" id="menu_action_delivery_carrier_form" parent="menu_delivery" groups="base.group_extended"/>

        <!-- 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>
            <field name="help">The delivery price list allows you to compute the cost and sales price of the delivery according to the weight of the products and other criteria. You can define several price lists for one delivery method, per country or a zone in a specific country defined by a postal code range.</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">
                    <group colspan="5" col="5">
                        <field colspan="4" name="name" select="1"/>
                        <newline/>
                        <field name="type" string="Condition"/>
                        <field name="operator" nolabel="1"/>
                        <field name="max_value" nolabel="1"/>
                    </group>
                    <newline/>
                    <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" nolabel="1"/>
                    <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="logistics" position="inside">
                    <field name="id" invisible="True"/>
                    <field name="carrier_id" context="{'order_id':active_id or False}"/>
                </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="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_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">
                <group colspan="2" col="2" position="after">
                    <group colspan="2" col="2" groups="base.group_extended">
                        <separator string="Weights" colspan="2"/>
                        <field name="weight"/>
                        <field name="weight_net"/>
                    </group>
                </group>
            </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">
                <group colspan="2" col="2" position="after">
                    <group colspan="2" col="2" groups="base.group_extended">
                        <separator string="Weights" colspan="2"/>
                        <field name="weight"/>
                        <field name="weight_net"/>
                    </group>
                </group>
            </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':active_id}"/>
                    </xpath>
            </field>
        </record>

        <record id="view_delivery_order_inherit_stock" model="ir.ui.view">
            <field name="name">stock.picking.out.form</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[@string='Products']/group/button[@string='Create Invoice']" position="after">
                    <button name="%(report_shipping)d" string="Delivery Order" states="done,assigned" type="action" icon="gtk-print"/>
                </xpath>
            </field>
        </record>

       <record id="delivery_method_form_view_todo" model="ir.actions.todo">
           <field name="action_id" ref="action_delivery_carrier_form1"/>
           <field name="sequence">10</field>
       </record>

    </data>
</openerp>
