<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <record id="service_request_inherit_view_form" model="ir.ui.view">
            <field name="name">service.request.form</field>
            <field name="model">service.request</field>
            <field name="inherit_id" ref="odex_benefit.service_request_form"/>
            <field name="arch" type="xml">
                <xpath expr="//field[@name='service_max_amount']" position="after">
                    <field name="rent_period"
                           attrs="{'invisible': [('service_type', '!=', 'alternative_housing')],'required':[('service_type', '=','alternative_housing')]}"/>
                    <field name="project_create" invisible="1"/>
                    <field name="project_id" readonly="1"
                           attrs="{'invisible': ['|',('project_create', '=',False),('project_id', '=',False)]}"/>
                    <field name="project_expected_delivery_date" readonly="1"
                           attrs="{'invisible': ['|',('project_create', '=',False),('project_expected_delivery_date', '=',False)]}"/>
                </xpath>
                <xpath expr="//header/button[@name='action_projects_department_approve']" position="attributes">
                    <attribute name="states"/>
                    <attribute name="attrs">{'invisible': ['|',('state', '!=', 'projects_department'),('project_create',
                        '=', True)]}
                    </attribute>
                </xpath>
                <xpath expr="//header/button[@name='action_first_refuse'][5]" position="attributes">
                    <attribute name="states"/>
                    <attribute name="attrs">{'invisible': ['|',('state', '!=', 'projects_department'),('project_create',
                        '=', True)]}
                    </attribute>
                </xpath>
                <xpath expr="//header/button[@name='action_refuse'][6]" position="attributes">
                    <attribute name="states"/>
                    <attribute name="attrs">{'invisible': ['|',('state', '!=', 'projects_department'),('project_create',
                        '=', True)]}
                    </attribute>
                </xpath>
                <xpath expr="//sheet/div[hasclass('oe_button_box')]" position="after">
                    <div attrs="{'invisible': [('project_id','=',False)]}">
                        <header>
                            <field name="project_state"

                                   widget="statusbar" readonly="1" nolabel="1"/>
                        </header>
                    </div>
                </xpath>
            </field>
        </record>
    </data>
</odoo>
