简体   繁体   中英

Find Xpath expresion in odoo 8

I want to find a XPath expression in odoo 8 because i want to replace a word in english into french.

I tried this :

<?xml version="1.0"?>
<openerp>
<data>
<template id="bonus_french_inherit" inherit_id="point_of_sale.index" name="bonusfrench assets">
<xpath expr="/div[not(@id) and not(@class)]/div[text()='Customer name']" position="attributes">
<attribute name="string">Nom du client</attribute>
</xpath>
</template>
</data>
</openerp>

In the ticket of point of sale I have this : ticket point of sale

When I inspect the element of the ticket in point of sale I have this :

 <div class="pos-sale-ticket">

 <div class="pos-center-align">.....</div>

 <div class="pos-center-align" id="ticket-barcode">.....</div>

 <div id="company_logo"><img style="padding-top: 4px; height: 50px; max-width: 100%;" src="...."></div>

 <br>

 Téléphone : <br>

 <br>

 <div>Customer name:.........<br></div>


 <div>Customer bonus points: 380<br><br></div>

So, my question is : How to find the Xpath expression for the Customer name and Customer bonus points, they don't have ID or class. How to find their expression Xpath ?

Note : Customer name and Customer bonus points appertain to a module named "pos_loyality", and in the view xml, they are declarend like that :

<t t-extend="PosTicket">
<t t-jquery=".pos-sale-ticket table:first" t-operation="before">
<t t-if="customer_name">
<div>Customer name: <t t-esc="customer_name"/><br /></div>
</t>
<t t-if="customer_loyalty_points > -1">
<div>Customer bonus points: <t t-esc="customer_loyalty_points"/><br /><br /></div>
</t>
</t>
</t>

Thank's a lot !

To translate from English into any other language, use the i18n tools integrated in Odoo. All text nodes in QWeb templates are exported into ".po" files, which you have to place in your /i18n directory, eg fr.po for French. From there, they are automatically imported on module installation/update.

Find relevant documentation here: https://www.odoo.com/documentation/8.0/reference/translations.html

Remove the "xpath" directive from your inherited template. Then follow the instructions in the documentation to export, creating your own fr.po file. Place this in your modules's "i18n" directory. Then re-install/update your module.

Edit: I couldn't find a module pos_loyalty in the standard Odoo 8.0 repo. If this is a non-standard module, it may just be missing a French translation. You can check the original point_of_sale module's fr.po for reference here: https://github.com/odoo/odoo/blob/8.0/addons/point_of_sale/i18n/fr.po

Try to use below expressions:

  • For Customer name

     substring-after(//div[starts-with(., "Customer name:")], "Customer name:") 
  • For Bonus

     substring-after(//div[starts-with(., "Customer bonus points:")], "Customer bonus points:") 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM