Contributors mailing list archives


Re: Odoo10 QWeb issues with translation

Open Architects Consulting, Houssine BAKKALI
- 06/02/2018 15:51:27
they changed the behavior with v9 and yes they didn't provide id or name to rely on which make extending view a pain... Anyway in last resort you can always override the whole view... you should ensure that you don't break the inherit hierarchy. note that it's no applicable in all cases and always take it like the last option as its a bad practice too (responding to a bad design)...

2018-02-06 15:17 GMT+01:00 Mohamed M. Hagag <>:

I know but in many cases there's no identifier other than the text itself, like table headers that have no id, class or name.

Also the same method was working fine in v8 , I think it's more reasonable to apply inheritance 1st then translate the resulting view as last step.

and it was working like that in v8.

On 02/06/2018 03:17 PM, Houssine BAKKALI wrote:
Hi Mohamed,

This is a bad practice to base xpath expr on litteral than may be changed through translation. This is the main reason why we can't base anymore xpath query on string attribute in Odoo.

You should find another way like accessing the child through name or class attribute and the accessing the parent through ".." expression

Hope it helps,

2018-02-05 21:02 GMT+01:00 Mohamed M. Hagag <>:

Hi All,

We are facing many issues with Odoo 10 and language translation, one of them is that when we inherit a qweb report view and add fields using the xpath node text - which is in English - the new view works fine in English but in other language the system says that the node does not exist in the parent view - due to change of the text because of translation .

example code:

new view:

<xpath expr="//th[.='Unit Price']" position="after">
                <th t-att-style="style" t-if="display_discount and doc.show_discount and doc.show_price" class="text-right" groups="sale.group_discount_per_so_line">Total</th>

in Arabic generates below error

ValueError: Element '<xpath expr="//th[.='Unit Price']">' cannot be located in parent view -- because 'Unit price' translated to other string.

And I must select nodes by text not by index due to other inherit views that change the index and the node does not have id or other selector.

Another Issue with translated error messages generates errors like: 

File "/opt/O10/odoo/odoo/odoo/addons/base/ir/", line 595, in apply_inheritance_specs
    self.raise_view_error(_("Element '%s' cannot be located in parent view") % tag, inherit_id)
TypeError: not all arguments converted during string formatting

This error because the previous error message - ValueError: Element ...etc - have been translated and the system can not load the utf-8 translation.

Note: I tried both cases on v10 build community and enterprise and got the same errors.

This doesn't happen in Odoo v8.0 and everything related to translation/utf8 is working fine.
can anyone explain what have technically changed in Odoo 10 related to translation handling and UTF-8 string formatting ?

Does Odoo10 translate strings before apply_inheritance on views ?? and why ? 

should Odoo10 adapt the new string.format() instead of using % as some developers claims that the later causes issues with UTF in latest python versions ?

System specs:

1- one server is ubuntu 16.04 with python 2.7.13 and postgres 9.6 
2- the other one is debian 9 with python 2.7.13 and postgres 9.6

Also I tried Centos7 with python 2.7.5/6 and postgres 9.4 << this generates same errors and more.

Any help is so appreciated.


Post to:

Post to:

Post to: