Contributors mailing list archives
Re: Odoo10 QWeb issues with translationby
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.
HoussineHope it helps,You should find another way like accessing the child through name or class attribute and the accessing the parent through ".." expressionHi 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.2018-02-05 21:02 GMT+01:00 Mohamed M. Hagag <email@example.com>:
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 .
<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_
in Arabic generates below errorValueError: 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/ir_ui_view.py", 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 runbot.odoo.com 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. Regards,