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

        <record id="edit_project_inherited" model="ir.ui.view">
            <field name="name">project.project.form.inherit</field>
            <field name="model">project.project</field>
            <field name="inherit_id" ref="project.edit_project"/>
            <field name="arch" type="xml">
                <data>
                    <xpath expr="//field[@name='allowed_internal_user_ids']" position="after">
                        <field name="is_sub_project" invisible="1"/>
                    </xpath>
                    <xpath expr="//field[@name='allowed_internal_user_ids']" position="after">
                        <field name="parent_project" attrs="{'invisible': [('is_sub_project', '=', False)]}"/>
                    </xpath>
                    <xpath expr="//field[@name='allowed_internal_user_ids']" position="after">
                        <field name="sub_project" widget="many2many_tags" attrs="{'invisible': [('is_sub_project', '=', True)]}"
                                       options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"/>
                    </xpath>
                    <!--<xpath expr="//page[@name='settings']" position="after">
                        <page name="sub_project" string="Sub Project"
                              attrs="{'invisible': [('is_sub_project', '=', True)]}">
                            <group>
                                <field name="sub_project" widget="many2many_tags"
                                       options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"/>
                            </group>
                        </page>
                    </xpath>-->

                </data>
            </field>
        </record>

        <record id="inherit2_view_task_tree2" model="ir.ui.view">
            <field name="name">project.task.tree.inherit</field>
            <field name="model">project.task</field>
            <field name="inherit_id" ref="project.view_task_tree2"/>
            <field name="arch" type="xml">
                <xpath expr="//field[@name='stage_id']" position="before">
                    <field name="sub_project" widget="many2many_tags"/>
                </xpath>
            </field>
        </record>

        <!--<record id="inherit_view_sub_project_tree" model="ir.ui.view">
            <field name="name">project.project.tree.inherit</field>
            <field name="model">project.project</field>
            <field name="inherit_id" ref="project.view_project"/>
            <field name="arch" type="xml">
                <xpath expr="//field[@name='partner_id']" position="after">
                </xpath>
            </field>
        </record>-->

        <record id="view_sub_project" model="ir.ui.view">
            <field name="name">project.sub.project.tree</field>
            <field name="model">project.project</field>
            <field name="arch" type="xml">
                <tree decoration-muted="active == False" string="Projects" delete="0" multi_edit="1" sample="1">
                    <field name="sequence" optional="show" widget="handle"/>
                    <field name="message_needaction" invisible="1"/>
                    <field name="active" invisible="1"/>
                    <field name="name" string="Name" class="font-weight-bold"/>
                    <field name="user_id" optional="show" string="Project Manager" widget="many2one_avatar_user"/>
                    <field name="partner_id" optional="show" string="Customer"/>
                    <!-- custom field -->
                    <field name="parent_project"/>
                    <!-- -->
                    <field name="analytic_account_id" optional="hide"/>
                    <field name="privacy_visibility" optional="hide"/>
                    <field name="subtask_project_id" optional="hide"/>
                    <field name="label_tasks" optional="hide"/>
                    <field name="company_id" optional="show"  groups="base.group_multi_company"/>
                </tree>
            </field>
        </record>

        <!-- SUB PROJECT VIEW-->
        <record id="action_sub_project" model="ir.actions.act_window">
            <field name="name">Sub Project</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">project.project</field>
            <field name="view_mode">tree,form</field>
            <field name="view_id" ref="view_sub_project"/>
            <!--<field name="search_view_id" ref="sale_order_view_search_inherit_sale"/>-->
            <field name="context">{'default_is_sub_project': True}</field>
            <field name="domain">[('is_sub_project', '=', True)]</field>
            <!--<field name="help" type="html">
                <p class="o_view_nocontent_smiling_face">
                    Create a new sub project
                </p>
            </field>-->
        </record>

        <menuitem id="menu_sub_project"
                  name="Sub Project"
                  action="action_sub_project"
                  parent="project.menu_main_pm"
                  sequence="2"/>

    </data>
</odoo>