Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xpath using "string" attribute #1

Open
badbole opened this issue Aug 17, 2015 · 9 comments
Open

xpath using "string" attribute #1

badbole opened this issue Aug 17, 2015 · 9 comments

Comments

@badbole
Copy link

badbole commented Aug 17, 2015

"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
Copy link
Owner

Hi @badbole,

Thanks a lot for reporting this! 👍
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
Copy link
Author

badbole commented Aug 18, 2015

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
Copy link
Owner

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

@badbole
Copy link
Author

badbole commented Oct 5, 2015

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

@Yenthe666
Copy link
Owner

@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
Copy link

this is the solution kid`s

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

@gfcapalbo
Copy link

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
Copy link
Owner

Yenthe666 commented Jul 12, 2016

@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
Copy link

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants