Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

Help with XPath and View Inheritance

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
viewsfieldsinheritancexpath
4 Odpowiedzi
70139 Widoki
Awatar
Bob Berger

Hello,

I am having trouble using XPath to do anything with views. I've read a lot on StackOverflow and Odoo's official documentation about XPath and view inheritance, but I don't understand how to use it because it never seems to work for me. i am using the inventory app. If I use the following in my view, it correctly makes the list_price field invisible

<odoo>
    <data>
        <record id="view_kit_product_form" model="ir.ui.view">
            <field name="name">kit_product_form</field>
            <field name="model">product.template</field>
            <field name="inherit_id" ref="product.product_template_form_view"/>
                     <field name="arch" type="xml">                             
                        <field name="list_price" position="attributes">
                            <attribute name="invisible">True</attribute>
                        </field>                    
                     </field>
        </record>
    </data>
</odoo>

but replacing

<field name="list_price" position="attributes">
      <attribute name="invisible">True</attribute>
</field>

with

<xpath expr="/form/sheet/notebook/page/group/group/field[name='list_price']" position="attributes">
    <attribute name="invisible">True</attribute>
</xpath>

or

<xpath expr="//field[@name='list_price']" position="attributes">
<attribute name="invisible">True</attribute>
</xpath>

or

<xpath expr="field[@name='list_price']" position="attributes">
<attribute name="invisible">True</attribute>
</xpath>

will always cause an error which creates a server error and tells me this:

Element '<xpath expr="field[@name=list_price]">' cannot be located in parent view.

In fact, trying to do anything with XPath has given me this error, and I don't understand why.

Shouldn't

<xpath expr="field[@name='list_price']"/>

Do the same thing as

<field name="list_price"/>

?

Can anybody tell me what I'm doing wrong? Or if there are any better resources which explain how to use XPath with Odoo and view inheritance, I would really appreciate it if you could tell me about them! I've seen people say you can use XPath with a view to even hide pages in a notebook in a form, but trying to do that also gives me an error.

Any help would be greatly appreciated

0
Awatar
Odrzuć
Mohammed Amal N

Hi, try this <xpath expr="//page[@name='general_information']/field[@name='list_price']" position="attributes">

Bob Berger
Autor

That gives the same error:

Element '<xpath expr="//page[@name='general_information']/field[@name='list_price']">' cannot be located in parent view

thompsonn

Shouldn't

<xpath expr="field[@name='list_price']"/>

Do the same thing as

<field name="list_price"/>

?

It shouldn't as you're telling the machine to search on the top level only. Instead, it should be:

<xpath expr="//field[@name='list_price']" position="attributes">

...

</xpath>

But my guess is that you just have missed leading '//' for the second time. I tried your code, it all works fine except for the one without leading '//'. You should probably try checking the spelling.

Bob Berger
Autor

Thank you thompsonn! You are right, and that is a helpful explanation that it is only searching the top level if you leave out "//"

thompsonn

Posted it as an answer, please don't hesitate to mark it as accepted :) Thanks

Sehrish

Read this: https://goo.gl/fGNfBY

Awatar
thompsonn
Najlepsza odpowiedź
Shouldn't
<xpath expr="field[@name='list_price']"/>
Do the same thing as
<field name="list_price"/>
?

It shouldn't as you're telling the machine to search on the top level only. Instead, it should be:

<xpath expr="//field[@name='list_price']" position="attributes">
...
</xpath>

But my guess is that you just have missed leading '//' for the second time. I tried your code, it all works fine except for the one without leading '//'. You should probably try checking the spelling.

1
Awatar
Odrzuć
Awatar
Sehrish
Najlepsza odpowiedź

Can anybody tell me what I'm doing wrong? Or if there are any better resources which explain how to use XPath with Odoo and view inheritance...
Yes why not I found some useful resources about XPath and inheritance in views and models.
http://learnopenerp.blogspot.com/2018/01/inheritance-in-models-and-views.html
Have a look into hope its helpful for you and others.
Thanks

1
Awatar
Odrzuć
Sehrish

Inheritance in models and views: http://learnopenerp.blogspot.com/2018/01/inheritance-in-models-and-views.html

Awatar
Ali Raza
Najlepsza odpowiedź

To clearify here, '//field['foofield']' won't work if their ain't any field of name foofield, you'll have to look for element props. If you wanna search for an element in table, use //table['@name='footable']. good luck.

0
Awatar
Odrzuć
Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
Extension View - Multiple xpath replacements Rozwiązane
views inheritance xpath
Awatar
Awatar
Awatar
2
maj 24
3987
How to hide a button that is identified by its action id ?
views inheritance xpath
Awatar
Awatar
Awatar
4
wrz 20
7081
Replace xpath expr with xpath
views xml inheritance xpath
Awatar
0
sie 21
4168
How to add a field in an inherited group? Rozwiązane
views fields xpath odoov12
Awatar
Awatar
Awatar
Awatar
5
sie 19
10302
[ODOO 10] "Unknown field in domain" error when inheriting a view to add sub-fields
views fields inheritance one2many
Awatar
Awatar
1
sty 18
8048
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now