How to remove an attribute from xml tag

In some cases, you need to remove an attribute from existing XML tag. In Odoo that is possible by selecting the tag and setting up no value for the attribute.
For example, if you want to remove readonly attribute from the user_id field you can do that in the following way:

<field name="user_id" position="attributes">
    <attribute name="readonly"/>

Also you can select the user_id field by using XPath:

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


  1. Ubaid ur Rehman

    I had tried this code it works when any field made readonly without any condition like
    “” but not in case:

    What is solution for that case?

  2. Ubaid ur Rehman

    The xml tags are ommited by the web

    *without condition like readonly=”True”
    * but not in case:

  3. admin

    Hi Ubaid,

    Sorry for the late response.

    In your case, you need to remove “attrs” instead of “readonly”.

Leave a Reply

Your email address will not be published. Required fields are marked *