<?xml version="1.0" encoding="utf-8" ?>
<!--
     Copyright 2017 ForgeFlow S.L.
     License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>
    <record id="purchase_order_form" model="ir.ui.view">
        <field name="name">purchase.order.form.block.reason</field>
        <field name="model">purchase.order</field>
        <field name="inherit_id" ref="purchase.purchase_order_form" />
        <field name="arch" type="xml">
            <button name="button_draft" position="attributes">
                <attribute name="states">cancel,to approve</attribute>
            </button>
            <field name="date_order" position="after">
                <field
                    name="approval_block_id"
                    force_save="1"
                    attrs="{'readonly': ['|',('approval_blocked','=', True), ('state', 'not in', 'draft')]}"
                />
                <field name="approval_blocked" invisible="True" />
            </field>
            <xpath expr="//header/button[@name='button_confirm']" position="before">
                <button
                    name="button_release_approval_block"
                    string="Release Approval Block"
                    type="object"
                    class="btn-primary"
                    groups="purchase_order_approval_block.group_rfq_approval_block"
                    attrs="{'invisible': ['|',('approval_block_id', '=', False),
                        ('state', 'not in', ['draft', 'sent'])]}"
                />
            </xpath>
        </field>
    </record>
    <record id="view_purchase_order_filter" model="ir.ui.view">
        <field name="name">request.quotation.select.block.reason</field>
        <field name="model">purchase.order</field>
        <field name="inherit_id" ref="purchase.view_purchase_order_filter" />
        <field name="arch" type="xml">
            <field name="product_id" position="after">
                <field name="approval_block_id" />
            </field>
            <filter name="approved" position="after">
                <filter
                    string="Blocked for Approval"
                    name="blocked_po"
                    domain="[('approval_block_id', '!=', False)]"
                />
            </filter>
        </field>
    </record>
</odoo>
