<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright 2014-2020 Akretion (http://www.akretion.com/)
  @author Alexis de Lattre <alexis.delattre@akretion.com>
  License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->

<odoo>

<record id="view_inventory_form" model="ir.ui.view">
    <field name="name">usability.stock.inventory.form</field>
    <field name="model">stock.inventory</field>
    <field name="inherit_id" ref="stock.view_inventory_form"/>
    <field name="arch" type="xml">
        <button name="action_open_inventory_lines" states="confirm" position="after">
            <button name="action_open_inventory_lines" states="done" string="Show Inventory Lines" type="object"/>
        </button>
        <field name="prefill_counted_quantity" position="attributes">
            <attribute name="attrs">{}</attribute>
        </field>
        <button name="action_validate" type="object" position="attributes">
            <attribute name="confirm">Do you confirm the validation of the inventory?</attribute>
        </button>
        <button name="action_validate" class="oe_highlight" position="attributes">
            <attribute name="confirm">Do you confirm the validation of the inventory?</attribute>
        </button>
        <!-- I would like to have the same confirm pop-up for the button
             "Validate Inventory" on the tree view of the inventory lines,
              but it's a special JS widget, so it's more complex to implement
        -->
    </field>
</record>
 
<record id="stock_inventory_line_tree" model="ir.ui.view">
    <field name="name">usability.stock.inventory.line.tree</field>
    <field name="model">stock.inventory.line</field>
    <field name="inherit_id" ref="stock.stock_inventory_line_tree"/>
    <field name="arch" type="xml">
        <field name="product_id" position="after">
            <field name="product_barcode" optional="hide"/>
        </field>
        <tree position="attributes">
            <!-- native :
            decoration-danger="product_qty != theoretical_qty"
            decoration-muted="product_qty == theoretical_qty"
            decoration-bf="is_editable"
            -->
            <attribute name="decoration-info">product_qty &gt; theoretical_qty</attribute>
            <attribute name="decoration-danger">product_qty &lt; theoretical_qty</attribute>
        </tree>
        <field name="location_id" position="attributes">
            <attribute name="invisible">0</attribute>
        </field>
    </field>
</record>

<record id="stock_inventory_line_search" model="ir.ui.view">
    <field name="name">usability.stock.inventory.line.search</field>
    <field name="model">stock.inventory.line</field>
    <field name="inherit_id" ref="stock.stock_inventory_line_search"/>
    <field name="arch" type="xml">
        <field name="product_id" position="after">
            <field name="categ_id"/>
        </field>
        <filter name="difference" position="after">
            <filter string="Difference = 0"
                    name="counted_equal" domain="[('difference_qty', '=', 0)]"/>
            <filter string="Counted lower than Theoretical"
                    name="counted_lower" domain="[('difference_qty', '&lt;', 0)]"/>
            <filter string="Counted higher than Theoretical"
                    name="counted_higher" domain="[('difference_qty', '&gt;', 0)]"/>
            <separator/>
            <filter string="Counted" name="counted" domain="[('product_qty', '>', 0)]"/>
        </filter>
    </field>
</record>
 
</odoo>
