This question has been flagged
6 Replies
3281 Views

I have a request to show out a field without moving to debug mode, the field was set as group_no_one.

Detail

<record id="project_invoice_form" model="ir.ui.view">
            <field name="name">Inherit project form : Invoicing Data</field>
            <field name="model">project.project</field>
            <field name="inherit_id" ref="project.edit_project"/>
            <field name="priority">24</field>
            <field name="arch" type="xml">
                <button name="toggle_active" position="before">
                    <button class="oe_stat_button" name="%(act_hr_timesheet_line_by_project)d" type="action" icon="fa-calendar" string="Timesheets" attrs="{'invisible': [('allow_timesheets', '=', False)]}                              "/>
                </button>
                <field name="user_id" position="after">
                    <field name="subtask_project_id" groups="base.group_no_one" attrs="{'invisible': [('allow_timesheets', '=', False)]}"/>
                </field>
                <xpath expr="//div[@name='options_active']" position="inside">
                    <div>
                        <field name="allow_timesheets" class="oe_inline" string="Allow timesheets"/>
                        <label for="allow_timesheets"/>
                    </div>
                </xpath>
            </field>
        </record>

How can I override field name subtask_project_id from groups="base.group_no_one" to other ?


Thanks.

Avatar
Discard
Author

I can override the field by those code.

<record id="edit_project_inherit" model="ir.ui.view">

<field name="name">Edit project inherit</field>

<field name="model">project.project</field>

<field name="inherit_id" ref="project.edit_project"/>

<field name="arch" type="xml">

<field name="user_id" position="after">

<field name="subtask_project_id" position="attributes">

<attribute name="groups"></attribute>

</field>

</field>

</field>

</record>

Author Best Answer

I followed your instruction, however I got this error

Element '<field name="subtask_project_id">' cannot be located in parent view

I found out that the field was inside field name "user_id", the field only showed if "user_id" exist.

Should I do like this?

<record id="oiginal_view_id_form_inherit" model="ir.ui.view">
<field name="name">pproject.project.inherit</field>
<field name="model">project.project</field>
<field name="inherit_id" ref="module_name.oiginal_view_id"/>
<field name="arch" type="xml">
        <field name="user_id>
    <field name="subtask_project_id" position="attributes">
    <attribute name="groups"></attribute>
    </field>
        </field>
</field>
</record>
Avatar
Discard

please replace module_name.oiginal_view_id with the "module name" and "original view id"

Author

I did, here is detail

<record id="edit_project_inherit" model="ir.ui.view">

<field name="name">project.project.inherit</field>

<field name="model">project.project</field>

<field name="inherit_id" ref="project.edit_project"/>

<field name="arch" type="xml">

<field name="subtask_project_id" position="attributes">

<attribute name="groups"></attribute>

</field>

</field>

</record>

Best Answer

Hi,

You can inherit the above view, and change the attributes of the corresponding field.

<record id="oiginal_view_id_form_inherit" model="ir.ui.view">
<field name="name">pproject.project.inherit</field>
<field name="model">project.project</field>
<field name="inherit_id" ref="module_name.oiginal_view_id"/>
<field name="arch" type="xml">
<field name="subtask_project_id" position="attributes">
<attribute name="groups"></attribute>
</field>

</field>
</record>

Also see this: https://www.youtube.com/watch?v=ZrCN3L0oAKE


Thanks

Avatar
Discard
Best Answer

try below command after inherited view

<field name="groups_id" eval="[(6,0,[ref('module_name.group')])]"/>
Avatar
Discard