<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <!-- Search View -->
    <record id="hazard_inventory_report_view_search" model="ir.ui.view">
        <field name="name">hazard.inventory.report.search</field>
        <field name="model">hazard.inventory.report</field>
        <field name="arch" type="xml">
            <search string="Búsqueda de Inventario">
                <field name="location_id"/>
                <field name="product_id"/>
                <field name="categ_id"/>
                <group expand="0" string="Agrupar por">
                    <filter string="Ubicación (Sucursal)" name="group_by_location" context="{'group_by':'location_id'}"/>
                    <filter string="Producto" name="group_by_product" context="{'group_by':'product_id'}"/>
                    <filter string="Categoría" name="group_by_categ" context="{'group_by':'categ_id'}"/>
                </group>
            </search>
        </field>
    </record>

    <!-- Tree View -->
    <record id="hazard_inventory_report_view_tree" model="ir.ui.view">
        <field name="name">hazard.inventory.report.tree</field>
        <field name="model">hazard.inventory.report</field>
        <field name="arch" type="xml">
            <tree string="Reporte de Inventario" create="false" edit="false" delete="false">
                <field name="location_id"/>
                <field name="product_id"/>
                <field name="categ_id" optional="hide"/>
                <field name="quantity" sum="Total Cantidad"/>
                <field name="standard_price" widget="monetary" options="{'currency_field': 'currency_id'}"/>
                <field name="list_price" widget="monetary" options="{'currency_field': 'currency_id'}"/>
                <field name="total_cost" sum="Costo Total" widget="monetary" options="{'currency_field': 'currency_id'}"/>
                <field name="total_sale" sum="Venta Total" widget="monetary" options="{'currency_field': 'currency_id'}"/>
            </tree>
        </field>
    </record>

    <!-- Pivot View -->
    <record id="hazard_inventory_report_view_pivot" model="ir.ui.view">
        <field name="name">hazard.inventory.report.pivot</field>
        <field name="model">hazard.inventory.report</field>
        <field name="arch" type="xml">
            <pivot string="Reporte Dinámico de Inventario" sample="1" disable_linking="True">
                <field name="location_id" type="row"/>
                <field name="product_id" type="row"/>
                <field name="quantity" type="measure"/>
                <field name="total_cost" type="measure"/>
                <field name="total_sale" type="measure"/>
            </pivot>
        </field>
    </record>

    <!-- Action -->
    <record id="action_hazard_inventory_report" model="ir.actions.act_window">
        <field name="name">Inventario por Sucursal (Costo y Precio)</field>
        <field name="res_model">hazard.inventory.report</field>
        <field name="view_mode">tree,pivot</field>
        <field name="context">{'search_default_group_by_location': 1}</field>
    </record>

    <!-- Menu Item (Under Inventory -> Reporting) -->
    <menuitem id="menu_hazard_inventory_report"
              name="Inventario por Sucursal"
              parent="stock.menu_warehouse_report"
              action="action_hazard_inventory_report"
              sequence="150"/>

</odoo>
