Yenthe666 / Odoo_Samples

This repository contains samples with Odoo code
GNU Affero General Public License v3.0
242 stars 306 forks source link

xpath using "string" attribute #1

Open badbole opened 9 years ago

badbole commented 9 years ago

"string" attribute sems to be depreciated in odoo9 ... need to check the code against trunk (future odoo v9)

this: expr="//page[@string='Information']/group" will not work anymore...

all other xpath handlers seems to work fine...

greetz bole ;)

Yenthe666 commented 9 years ago

Hi @badbole,

Thanks a lot for reporting this! :+1: Have you found any official statement about this or why this is the fact? This would be strange since Odoo 9 will support both the V7 and V8 API. I'm not sure why they would remove this..

Greetz Yenthe

badbole commented 9 years ago

I just came into it while migrating some custom modules to v9... not sure if it will be corrected, but it does not work for now in trunk version... try it yourself.. :)

Yenthe666 commented 9 years ago

@badbole,

I've finally had the time to test this and you're correct. Xpath string expressions have been fully removed in V9! (I added a note on my sample here: https://github.com/Yenthe666/Odoo_Samples/blob/master/xpath_expressions/templates.xml) I've found an issue a few days ago which stated that this is explicitly done and was no error from Odoo. Just can't find it anymore :tongue:

badbole commented 9 years ago

Told you so :) Good to know i was right :) btw.. .can't find example also.. will soon... Yah... karma not won on forum :)

Yenthe666 commented 9 years ago

@bole,

Some alternative methods: Expr="//page[2]" Expr="//field[@name='fieldname']"

I guess there are plenty of other ways. I did like the old string option though..

reinaldopr0 commented 8 years ago

this is the solution kid`s

xpath expr="//page[2]" position = "attributes"> page> attribute name="invisible">True /page>

gfcapalbo commented 8 years ago

is xpathing by number safe? every time I see that i think "who tells you it's always going to be second?" I prefer name, looks safer.

Yenthe666 commented 8 years ago

@gfcapalbo you should always go for the name if you can, it is by far better. Every once in a blue moon there is no name and then you'll need to specify an index though, just don't do it if you don't have to.

Edit: if you make an xpath with an index and the index is out of range you'll get one ugly error.

alesisjoan commented 2 months ago

for someone get to this, you can find some field and get the parent

expr="//field[@name='some_field']/parent::page"