<?xml version="1.0"?>
<!--
##############################################################################
#
#    Copyright (C) 2009-2011  Akretion, Emmanuel Samyn
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
-->

<openerp>
    <data>
<!-- return instructions -->
       <!-- supplier info tree view -->
        <record model="ir.ui.view" id="product_return_instructions_tree_view">
            <field name="name">product.return.instructions.tree</field>
            <field name="model">return.instruction</field>
            <field name="arch" type="xml">
                <tree string="Return instructions">
                    <field name="name"/>
                    <field name="instructions"/>
                    <field name="is_default"/>
                </tree>
            </field>
        </record>

        <!-- supplier info form view -->
        <record model="ir.ui.view" id="product_return_instructions_form_view">
            <field name="name">product.return.instructions.form</field>
            <field name="model">return.instruction</field>
            <field name="arch" type="xml">
                <form string="Return instructions">
                    <group col='4'>
                        <field name="name"/>
                        <field name="is_default"/>
                    </group>
                    <separator string="Instructions" colspan="4"/>
                    <field name="instructions" nolabel="1" colspan="4"/>
                </form>
            </field>
        </record>

        <record id="product_return_instructions_action" model="ir.actions.act_window">
            <field name="name">Products Return Instructions</field>
            <field name="res_model">return.instruction</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="view_id" ref="product_return_instructions_tree_view"/>
        </record>

        <menuitem action="product_return_instructions_action"
            groups="base.group_no_one"
            id="menu_product_return_instructions_action"
            parent="product.prod_config_main" sequence="3"/>
<!-- supplier info -->
        <!-- supplier info tree view -->
        <record model="ir.ui.view" id="product_supplierinfo_warranty_tree_view">
            <field name="name">product.supplierinfo.warranty.tree</field>
            <field name="model">product.supplierinfo</field>
            <field name="inherit_id" ref="product.product_supplierinfo_tree_view" />
            <field name="arch" type="xml">
                <xpath expr="//field[@name='delay']" position="after">
                    <field name="warranty_duration"/>
                    <field name="warranty_return_partner"/>
                    <field name="warranty_return_address"/>
                    <field name="active_supplier"/>
                    <field name="return_instructions"/>
                </xpath>
            </field>
        </record>

        <!-- supplier info form view -->
        <record model="ir.ui.view" id="product_supplierinfo_warranty_form_view">
            <field name="name">product.supplierinfo.warranty.form</field>
            <field name="model">product.supplierinfo</field>
            <field name="inherit_id" ref="product.product_supplierinfo_form_view" />
            <field name="arch" type="xml">
                <field position="after" name="company_id"  groups="base.group_multi_company" widget="selection">
                    <group string="Warranty informations" colspan="4">
                        <field name="active_supplier"/>
                        <field name="warranty_duration"/>
                        <field name="return_instructions"/>
                        <group colspan="4" col="6">
                            <group>
                                <field name="warranty_return_partner"/>
                            </group>
                            <group>
                                <field name="warranty_return_other_address" attrs="{'invisible':[('warranty_return_partner', '!=', 'other')], 'required':[('warranty_return_partner', '=', 'other')]}" class="oe_inline"/>
                                <field name="warranty_return_address" attrs="{'invisible':[('warranty_return_partner', '=', 'other')]}" class="oe_inline" />
                            </group>
                        </group>
                    </group>
                </field>
            </field>
        </record>

     </data>
</openerp>
