1

我想在 odoo 8 中找到一个 XPath 表达式,因为我想将英语中的一个单词替换为法语。

我试过这个:

<?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>

在销售点的票上,我有这个:ticket point of sale

当我在销售点检查票的元素时,我有这个:

 <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>

所以,我的问题是:如何找到客户名称和客户奖励积分的 Xpath 表达式,它们没有 ID 或类。如何找到他们的表达式 Xpath ?

注意:客户名称和客户奖励积分属于名为“pos_loyality”的模块,在视图 xml 中,它们是这样声明的:

<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>

非常感谢 !

4

2 回答 2

2

要将英语翻译成任何其他语言,请使用 Odoo 中集成的 i18n 工具。QWeb 模板中的所有文本节点都导出到“.po”文件中,您必须将其放在/i18n 目录中,例如法语的 fr.po。从那里,它们会在模块安装/更新时自动导入。

在此处查找相关文档:https ://www.odoo.com/documentation/8.0/reference/translations.html

从继承的模板中删除“xpath”指令。然后按照文档中的说明进行导出,创建自己的 fr.po 文件。将它放在模块的“i18n”目录中。然后重新安装/更新您的模块。

编辑:我在标准 Odoo 8.0 存储库中找不到模块 pos_loyalty。如果这是一个非标准模块,它可能只是缺少法语翻译。您可以在此处查看原始 point_of_sale 模块的 fr.po 以供参考: https ://github.com/odoo/odoo/blob/8.0/addons/point_of_sale/i18n/fr.po

于 2018-04-15T16:16:52.867 回答
1

尝试使用以下表达式:

  • 对于客户名称

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

    substring-after(//div[starts-with(., "Customer bonus points:")], "Customer bonus points:")
    
于 2018-04-15T10:06:27.623 回答