Lukas
Lukas

Reputation: 2312

Odoo List view: set column to be always visible

I'm working with Odoo 14 and would like to know if there is an option in XML template to suppress optional="show"/"hide" setting inherited from parent template. For example I have following code in parent template:

<field name="code" optional="show" readonly="1"/>

On a child template I would like to do something like this:

<xpath expr="//field[@name='code']" position="attributes">
    <attribute name="optional">Always on</attribute>
</xpath>

to set the code field to be always on, without option to hide or show the column. Is there any option to do so?

Upvotes: 0

Views: 774

Answers (2)

Ali Badran
Ali Badran

Reputation: 46

You can inherit that field's attribute and remove it.

<xpath expr="//field[@name='code']" position="attributes">
    <attribute name="optional"></attribute>
</xpath>

Upvotes: 2

Lukas
Lukas

Reputation: 2312

Solution is in fact easy, just to replace the inherited element with newly defined - without optional attribute. This rewrites all attribute settings.

<!-- In child template: -->
<xpath expr="//field[@name='code']" position="replace">
    <field name="code"/>
</xpath>

Upvotes: 0

Related Questions