This question has been flagged
6 Replies
18054 Views

Hello everybody here,

Still an strange mystery today... Look at this example. 

My goal : replace a <title> tag with xpath

Example 1 : See code and image. the new title is after the original one. It is what we want.

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <template id="index" inherit_id='point_of_sale.index' name="Index AS">&lt;!DOCTYPE html&gt; 
            <xpath expr="//title" position="after">
                <title>Odoo POS - AS</title>
            </xpath>
            <xpath expr="//link[@id='pos-stylesheet']" position="after">
                <link rel="stylesheet" href="/pos_lapagept/static/src/css/pos_as.css" />
            </xpath>
        </template>
        <template id="assets_backend" name="point_of_sale assets" inherit_id="point_of_sale.assets_backend">
            <xpath expr="//script[contains(@src,'widget_base.js')]" position="replace">
                <script type="text/javascript" src="/pos_lapagept/static/src/js/widget_base.js"></script>
            </xpath>
        </template>
    </data>
</openerp>

 

Example 2 : See code and image. the new title DOESN'T REPLACE the original one. It is NOT what we want. ????????? 

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <template id="index" inherit_id='point_of_sale.index' name="Index - AS">&lt;!DOCTYPE html&gt; 
            <xpath expr="//title" position="replace">
                <title>Odoo POS AS</title>
            </xpath>
            <xpath expr="//link[@id='pos-stylesheet']" position="after">
                <link rel="stylesheet" href="/pos_lapagept/static/src/css/pos_as.css" />
            </xpath>
        </template>
        <template id="assets_backend" name="point_of_sale assets" inherit_id="point_of_sale.assets_backend">
            <xpath expr="//script[contains(@src,'widget_base.js')]" position="replace">
                <script type="text/javascript" src="/pos_lapagept/static/src/js/widget_base.js"></script>
            </xpath>
        </template>
    </data>
</openerp>

 

What is the problem? Why could we not replace the title correctly?

 

Avatar
Discard
Author Best Answer

What we needed was :

<xpath expr="//title" position="replace">

        <title>Odoo POS - AS</title>

</xpath>

We don't know why, but this time, it works!

Avatar
Discard
Best Answer

Hi,

 <xpath expr="//title[1]" position="attributes">
                <attribute name="title">Odoo POS - AS</attribute>
  </xpath>

try this.............

Avatar
Discard
Author

With this test, I get :

It is not ok. Sorry and thanks.

You didnt get the expected result?....

Author

With your code, I get :

It is not like I want. Thanks

Then exactly what u want.......