<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2018 Simone Rubino - Agile Business Group
     License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
    <record id="action_qc_inspection_per_picking" model="ir.actions.act_window">
        <field name="name">Quality inspections from picking</field>
        <field name="res_model">qc.inspection</field>
        <field name="view_mode">tree,form</field>
        <field name="domain">[('picking_id', '=', active_id)]</field>
    </record>
    <record id="action_qc_inspection_per_picking_done" model="ir.actions.act_window">
        <field name="name">Quality inspection from picking done</field>
        <field name="res_model">qc.inspection</field>
        <field name="view_mode">tree,form</field>
        <field
            name="domain"
        >[('picking_id', '=', active_id), ('state', 'not in', ['draft', 'waiting'])]</field>
    </record>
    <record id="action_qc_inspection_per_picking_passed" model="ir.actions.act_window">
        <field name="name">Quality inspection from picking passed</field>
        <field name="res_model">qc.inspection</field>
        <field name="view_mode">tree,form</field>
        <field
            name="domain"
        >[('picking_id', '=', active_id), ('state', '=', 'success')]</field>
    </record>
    <record id="action_qc_inspection_per_picking_failed" model="ir.actions.act_window">
        <field name="name">Quality inspections from picking failed</field>
        <field name="res_model">qc.inspection</field>
        <field name="view_mode">tree,form</field>
        <field
            name="domain"
        >[('picking_id', '=', active_id), ('state', '=', 'failed')]</field>
    </record>
    <record model="ir.ui.view" id="stock_picking_qc_view">
        <field name="name">stock.picking.qc.view</field>
        <field name="model">stock.picking</field>
        <field name="inherit_id" ref="stock.view_picking_form" />
        <field
            name="groups_id"
            eval="[(4, ref('quality_control_oca.group_quality_control_user'))]"
        />
        <field name="arch" type="xml">
            <div name="button_box" position="inside">
                <button
                    class="oe_inline oe_stat_button"
                    type="action"
                    name="%(action_qc_inspection_per_picking)d"
                    icon="fa-list"
                >
                    <field
                        name="created_inspections"
                        widget="statinfo"
                        string="inspections"
                    />
                </button>
                <button
                    class="oe_inline oe_stat_button"
                    type="action"
                    name="%(action_qc_inspection_per_picking_done)d"
                    icon="fa-pencil"
                >
                    <field name="done_inspections" widget="statinfo" />
                </button>
                <button
                    class="oe_inline oe_stat_button"
                    type="action"
                    name="%(action_qc_inspection_per_picking_passed)d"
                    icon="fa-thumbs-o-up"
                >
                    <field name="passed_inspections" widget="statinfo" />
                </button>
                <button
                    class="oe_inline oe_stat_button"
                    type="action"
                    name="%(action_qc_inspection_per_picking_failed)d"
                    icon="fa-thumbs-o-down"
                >
                    <field name="failed_inspections" widget="statinfo" />
                </button>
            </div>
        </field>
    </record>
</odoo>
