<openerp>
    <data>

        <record id="action_claim_from_delivery" model="ir.actions.act_window">
            <field name="name">Claim From Delivery</field>
            <field name="res_model">crm.claim</field>
            <field name="view_type">form</field>
            <field name="view_id" ref="crm_claim.crm_case_claims_tree_view"/>
            <field name="context">{'default_ref': 'stock.picking,'+str(context.get('active_id', False))}</field>
            <field name="domain">[('ref','=','stock.picking,'+str(context.get('active_id',False)))]</field>
        </record>
        <record id="crm_claim_from_delivery" model="ir.ui.view">
            <field name="name">crm.claim.from_delivery.form</field>
            <field name="model">stock.picking</field>
            <field name="inherit_id" ref="stock.view_picking_form"/>
            <field name="groups_id" eval="[(4, ref('base.group_sale_salesman')), (4, ref('base.group_partner_manager'))]"/>
            <field name="arch" type="xml">
                <xpath expr="/form/sheet/h1" position="before">
                    <div class="oe_right oe_button_box">
                        <button class="oe_inline oe_stat_button" type="action" attrs="{'invisible': [('picking_type_code', '!=', 'outgoing')]}" 
                                name="%(action_claim_from_delivery)d" icon="fa-comments" >
                                <field string="Claims" name="claim_count_out" widget="statinfo"/>
                        </button>
                    </div>
                </xpath>
            </field>
        </record>
    </data>
</openerp>
