Hello everyone,
I have been trying to properly understand view inheritance in Odoo and I felt like I had a pretty good understanding of the mechanism until I stumbled upon a weird problem with XPath. I was interested in extending the "website_sale.checkout" view by adding extra attributes to an anchor tag.
This view contains a single anchor tag with the class value "btn-primary". This button is the button that is clicked to confirm an order. I simply made a custom module that would inherit the website_sale.checkout view and use an XPath expression to extend it.
The expression used was "//a[hasclass('btn-primary')]" and it somehow did not change anything on the resulting view. After agonizing over it for an hour, I tried to make the xpath expression a bit more expressive by changing the expression to "//div[hasclass('justify-content-between')]/a[hasclass('btn-primary')]" and it magically worked.
This seemed very confusing to me, because both expressions should lead to the same element (for this specific xml architecture). I even copied the whole view from website_sale.checkout and put it in a xml validator that also allowed xpath expressions to be tested. And on that test run both were equal.
My only plausible conclusion is that the shorter expression matches something else that is not intended, otherwise there should be an error message. But does that mean that an xpath expression is not just run on the xml architecture of the inherited view? Is there more at play here or can somebody explain this weirdness?
Kind regards