Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Kov
    • Nábytek
    • Jídlo
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • IT hardware a podpora
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

Help with XPath and View Inheritance

Odebírat

Get notified when there's activity on this post

This question has been flagged
viewsfieldsinheritancexpath
4 Odpovědi
70140 Zobrazení
Avatar
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
Avatar
Zrušit
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

Avatar
thompsonn
Nejlepší odpověď
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
Avatar
Zrušit
Avatar
Sehrish
Nejlepší odpověď

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
Avatar
Zrušit
Sehrish

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

Avatar
Ali Raza
Nejlepší odpověď

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
Avatar
Zrušit
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
Extension View - Multiple xpath replacements Vyřešeno
views inheritance xpath
Avatar
Avatar
Avatar
2
kvě 24
3988
How to hide a button that is identified by its action id ?
views inheritance xpath
Avatar
Avatar
Avatar
4
zář 20
7083
Replace xpath expr with xpath
views xml inheritance xpath
Avatar
0
srp 21
4168
How to add a field in an inherited group? Vyřešeno
views fields xpath odoov12
Avatar
Avatar
Avatar
Avatar
5
srp 19
10303
[ODOO 10] "Unknown field in domain" error when inheriting a view to add sub-fields
views fields inheritance one2many
Avatar
Avatar
1
led 18
8049
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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