Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Different position values used in xpath

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 5.70k
    Comment on it

    In Odoo/OpenERP many times we need to inherit views in order to add/remove/replace few elements of the original view. Simple use of `` can make that easier. With this tag we have to provide an attribute called "position". This attribute contains following values:

    • before
    • after
    • replace
    • inside
    • attributes

    e.g.

    <xpath expr="//path-to-element" position="before">
           ....
    </xpath>
    
    <xpath expr="//path-to-element" position="after">
          .....
    </xpath>
    

    You can use more than one <xpath> in one inherited view. The first four values i.e. before, after, replace and inside are self-explanatory. But there is one special value "attributes". This is used to modify a specific attribute of an element. For e.g. in original view we have a field

    <field name="note" readonly="1"/>
    

    In my inherited view I want to change/add some attributes to the above field. It goes like this:

    <xpath expr="//form/field[@name='note']" position="attributes">
         <attribute name="readonly">False</attribute>
         <attribute name="string">Description</attribute>
    </xpath>
    

    With the above code, field "note" will no longer be readonly and the label of the field will become "Description" on the view.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: