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í
    Food & Hospitality
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Guest House
    • Distributor nápojů
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Trades
    • Údržbář
    • IT hardware a podpora
    • Solar Energy Systems
    • Výrobce obuvi
    • Úklidové služby
    • HVAC Services
    Others
    • Nonprofit Organization
    • 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

Two-level view inheritance, what am I missing?

Odebírat

Get notified when there's activity on this post

This question has been flagged
viewinheritance
2 Odpovědi
6813 Zobrazení
Avatar
Miku Laitinen

I'm trying to create a hierarchy for custom sales quotation views. I have two types of quotations; spot and tariff. They cannot be defined in the same sale.order model without violating several best practices (DRY, NF, etc.). That's why I have created an abstract class that inherits from sale.order and adds common fields and functions for both of the quotations types. The quotations then inherit sale.order (with the additional fields and functions) and redefine the model name, sale.spot and sale.tariff respectively.

The model inheritance seems to be working just as I expected, but I'm having great difficulties inheriting the views. I created a form view view_order_form_general that changes some fields in the original sale.order form view (sale.view_order_form) and my spot & tariff form views inherit from view_order_form_general. When I load the form view, there are zero modifications. If I make the spot view inherit directly from sale.view_order_form, then the modifications are applied. But only the spot modifications. Not the general ones.

Is there something that prevents multi-level inheritance or is there something else that I'm missing here?

I tried to add a drawing here to further explain the inheritance, but apparently you need 30 karma for that..

sale_general.xml (omitted openerp and data tags):

<!-- General form view -->
<record id="view_order_form_general" model="ir.ui.view">
    <field name="name">sale.order.form.general</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_order_form"/>
    <field name="arch" type="xml">
        <data>
        ... general modifications ...
    </data>
    </field>
</record>

 

 

sale_spot.xml (omitted openerp and data tags):

<!-- Spot form view -->
<record id="view_order_form_spot" model="ir.ui.view">
    <field name="name">sale.order.form.spot</field>
    <field name="model">sale.spot</field>
    <field name="inherit_id" ref="view_order_form_general"/>
    <field name="arch" type="xml">
        <data>
        ... spot quotation specific modifications ...
    </data>
    </field>
</record>

<!-- Action for displaying spot view -->
<record id="action_spot_quotations" model="ir.actions.act_window">
    <field name="name">Spot quotations</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">sale.spot</field>
    <field name="view_type">form</field>
    <field name="view_mode">tree,form,calendar,graph</field>
    <field name="search_view_id" ref="sale.view_sales_order_filter"/>
    <field name="context">{}</field>
    <field name="help" type="html">
      <p class="oe_view_nocontent_create">
        Click to create a spot quotation.
      </p>
    </field>
</record>

<!-- Which form to show for a spot quotation -->
<record id="action_spot_quotations_form" model="ir.actions.act_window.view">
    <field name="view_mode">form</field>
    <field name="view_id" ref="view_order_form_spot" />
    <field name="act_window_id" ref="action_spot_quotations" />
</record>

 

1
Avatar
Zrušit
Avatar
Timothy Solomon
Nejlepší odpověď

There are a couple ways that you can specify which view to use. If you specify a view_id in your action_window, then it will use that. If you dont specify a view_id it will go through all the views and inherited views for that object and choose the one with the highest priority number. It looks like you have the view_ids set correctly so thats probably not the problem.

How are you over-riding the xml? are you using "replace" or inserting your tags "after" (eg <xpath expr="/form/group" position="after">)?

You could use the same view and rather hide / show the fields you need depending on whether it is a spot or tariff sale.

1
Avatar
Zrušit
Avatar
Miku Laitinen
Autor Nejlepší odpověď

Thank you Timothy for taking the time to answer.

Your suggestion to hide / show fields depending on the quotation type felt really tempting. The only thing I'm afraid of is that the more complex or different the quotation types grow, the more spaghetti-y views I will have.

So, I ended up copying all the fields from sale.view_order_form to my view_order_form_general. Instead of two levels of inheritance I now have only one level of inheritance for each quotation type. It seems to be working exactly as I want it to and the views will stay clean.

This answer doesn't actually solve my original problem (so I won't mark it as accepted), but it's more like a workaround. Hope it will help someone else with the same problem. I'd be very happy to see a real solution for this.

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
View inheritance Vyřešeno
view inheritance
Avatar
Avatar
1
bře 20
4341
How do I remove fields from a view in a custom module? Vyřešeno
view inheritance
Avatar
Avatar
Avatar
Avatar
12
pro 18
36175
Weird error "Expression cannot be located in parent view" in view inheritance Vyřešeno
view inheritance
Avatar
Avatar
1
čvc 16
7894
Problem with inheritance of a view. Vyřešeno
view inheritance
Avatar
Avatar
1
bře 15
8695
Is "search + use arch" the right way to derive a form ?
view inheritance
Avatar
0
bře 15
4564
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