<?xml version="1.0"?>
<!-- This file is part of Tryton.  The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
    <data>
        <record model="ir.ui.view" id="location_view_form">
            <field name="model">stock.location</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <![CDATA[
                    <form string="Location">
                        <label name="name"/>
                        <field name="name"/>
                        <label name="code"/>
                        <field name="code"/>
                        <label name="parent"/>
                        <field name="parent"/>
                        <label name="active"/>
                        <field name="active"/>
                        <label name="type"/>
                        <field name="type"/>
                        <newline/>
                        <label name="address"/>
                        <field name="address"/>
                        <newline/>
                        <label name="input_location"/>
                        <field name="input_location"/>
                        <newline/>
                        <label name="output_location"/>
                        <field name="output_location"/>
                        <newline/>
                        <label name="storage_location"/>
                        <field name="storage_location"/>
                    </form>
                ]]>
            </field>
        </record>
        <record model="ir.ui.view" id="location_view_tree">
            <field name="model">stock.location</field>
            <field name="type">tree</field>
            <field name="priority" eval="20"/>
            <field name="field_childs">childs</field>
            <field name="arch" type="xml">
                <![CDATA[
                    <tree string="Locations" keyword_open="1">
                        <field name="name"/>
                        <field name="code"/>
                        <field name="type"/>
                        <field name="active" tree_invisible="1"/>
                        <field name="parent" tree_invisible="1"/>
                        <field name="childs" tree_invisible="1"/>
                    </tree>
                ]]>
            </field>
        </record>
        <record model="ir.ui.view" id="location_view_list">
            <field name="model">stock.location</field>
            <field name="type">tree</field>
            <field name="priority" eval="10"/>
            <field name="arch" type="xml">
                <![CDATA[
                    <tree string="Locations">
                        <field name="name"/>
                        <field name="code"/>
                        <field name="type"/>
                        <field name="active" tree_invisible="1"/>
                    </tree>
                ]]>
            </field>
        </record>

        <record model="ir.action.act_window" id="act_location_tree">
            <field name="name">Locations</field>
            <field name="res_model">stock.location</field>
            <field name="domain">[('parent', '=', False)]</field>
        </record>
        <record model="ir.action.act_window.view" id="act_location_tree_view1">
            <field name="sequence" eval="10"/>
            <field name="view" ref="location_view_tree"/>
            <field name="act_window" ref="act_location_tree"/>
        </record>
        <record model="ir.action.act_window.view" id="act_location_tree_view2">
            <field name="sequence" eval="20"/>
            <field name="view" ref="location_view_form"/>
            <field name="act_window" ref="act_location_tree"/>
        </record>
        <menuitem parent="menu_stock" sequence="10"
            action="act_location_tree" id="menu_location_tree"/>

        <record model="ir.action.act_window" id="act_location_form">
            <field name="name">Locations</field>
            <field name="res_model">stock.location</field>
        </record>
        <record model="ir.action.act_window.view" id="act_location_form_view1">
            <field name="sequence" eval="10"/>
            <field name="view" ref="location_view_list"/>
            <field name="act_window" ref="act_location_form"/>
        </record>
        <record model="ir.action.act_window.view" id="act_location_form_view2">
            <field name="sequence" eval="20"/>
            <field name="view" ref="location_view_form"/>
            <field name="act_window" ref="act_location_form"/>
        </record>
        <menuitem parent="menu_configuration" sequence="10"
            action="act_location_form" id="menu_location_form"/>

        <record model="ir.action.act_window" id="act_products_by_locations">
            <field name="name">Products by Locations</field>
            <field name="res_model">product.product</field>
            <field name="window_name" eval="False"/>
            <field name="domain">['OR', ('quantity', '!=', 0.0), ('forecast_quantity', '!=', 0.0)]</field>
        </record>
        <record model="ir.action.act_window.view" id="act_product_form_view2">
            <field name="sequence" eval="10"/>
            <field name="view" ref="product_view_tree_qty"/>
            <field name="act_window" ref="act_products_by_locations"/>
        </record>
        <record model="ir.action.act_window.view" id="act_product_form_view">
            <field name="sequence" eval="20"/>
            <field name="view" ref="product.product_view_form"/>
            <field name="act_window" ref="act_products_by_locations"/>
        </record>

        <record model="ir.action.wizard" id="wizard_products_by_locations">
            <field name="name">Products by Locations</field>
            <field name="wiz_name">stock.products_by_locations</field>
            <field name="model">stock.location</field>
        </record>
        <record model="ir.action.keyword"
                id="act_products_by_locations_keyword1">
            <field name="keyword">tree_open</field>
            <field name="model">stock.location,-1</field>
            <field name="action" ref="wizard_products_by_locations"/>
        </record>

        <record model="ir.model.access" id="access_location">
            <field name="model" search="[('model', '=', 'stock.location')]"/>
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="False"/>
            <field name="perm_create" eval="False"/>
            <field name="perm_delete" eval="False"/>
        </record>
        <record model="ir.model.access" id="access_location_admin">
            <field name="model" search="[('model', '=', 'stock.location')]"/>
            <field name="group" ref="group_stock_admin"/>
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="True"/>
            <field name="perm_create" eval="True"/>
            <field name="perm_delete" eval="True"/>
        </record>

        <record model="ir.ui.view" id="party_view_form">
            <field name="model">party.party</field>
            <field name="inherit" ref="party.party_view_form"/>
            <field name="arch" type="xml">
                <![CDATA[
                <data>
                    <xpath
                        expr="/form/notebook/page[@id=&quot;accounting&quot;]"
                        position="after">
                        <page string="Stock" id="stock">
                            <label name="customer_location"/>
                            <field name="customer_location"/>
                            <label name="supplier_location"/>
                            <field name="supplier_location"/>
                        </page>
                    </xpath>
                </data>
                ]]>
            </field>
        </record>

        <record model="ir.ui.view" id="products_by_locations_start_view_form">
            <field name="model">stock.products_by_locations.start</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <![CDATA[
                <form string="Products by Locations">
                    <label name="forecast_date"/>
                    <field name="forecast_date"/>
                </form>
                ]]>
            </field>
        </record>

    </data>
    <data noupdate="1">
        <!-- Default locations -->
        <record model="stock.location" id="location_input">
            <field name="name">Input Zone</field>
            <field name="code">IN</field>
            <field name="type">storage</field>
        </record>
        <record model="stock.location" id="location_output">
            <field name="name">Output Zone</field>
            <field name="code">OUT</field>
            <field name="type">storage</field>
        </record>
        <record model="stock.location" id="location_storage">
            <field name="name">Storage Zone</field>
            <field name="code">STO</field>
            <field name="type">storage</field>
        </record>
        <record model="stock.location" id="location_warehouse">
            <field name="name">Warehouse</field>
            <field name="code">WH</field>
            <field name="type">warehouse</field>
            <field name="input_location" ref="location_input"/>
            <field name="output_location" ref="location_output"/>
            <field name="storage_location" ref="location_storage"/>
        </record>
        <record model="stock.location" id="location_supplier">
            <field name="name">Supplier</field>
            <field name="code">SUP</field>
            <field name="type">supplier</field>
        </record>
        <record model="stock.location" id="location_customer">
            <field name="name">Customer</field>
            <field name="code">CUS</field>
            <field name="type">customer</field>
        </record>
        <record model="stock.location" id="location_lost_found">
            <field name="name">Lost and Found</field>
            <field name="type">lost_found</field>
        </record>

        <record model="ir.property" id="property_supplier_location">
            <field name="field"
                   search="[('model.model', '=', 'party.party'),
                           ('name', '=', 'supplier_location')]"/>
            <field name="value" eval="'stock.location,' + str(ref('location_supplier'))"/>
        </record>
        <record model="ir.property" id="property_customer_location">
            <field name="field"
                   search="[('model.model', '=', 'party.party'),
                           ('name', '=', 'customer_location')]"/>
            <field name="value" eval="'stock.location,' + str(ref('location_customer'))"/>
        </record>
    </data>
</tryton>
