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

Views affect back on inherited views.

Odebírat

Get notified when there's activity on this post

This question has been flagged
viewsinheritancesequencepriority
2 Odpovědi
6474 Zobrazení
Avatar
Kai Brossmann

I have created a model and a view that inherits the sale.order view and adds som custom field to it. I do not want to modify the original sale order view.

This code will (almost) do what I need:

    <record id="work_order_form" model="ir.ui.view">
        <field name="name">Workorder Form View</field>
        <field name="model">sale.order</field>
        <field name="priority" eval="10"/>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <!--<field name="mode">primary</field> -->
        <field name="arch" type="xml">
            <xpath expr="//field[@name='partner_id']" position="after">
                <field name="custom_field_1"/>
                <field name="custom_field_2"/>
            </xpath>
        </field>
    </record>


Now within my model it will open the work order view and display my custom fields.Good!

Going back to the sales model you have two options 1. Quotation and  2. Order.

When I open a Sales order it has not changed the original sale.order.form view. Good!

But, still within the sale model if you open or create a new quotation though, it will also add my custom fields.

Within developer mode I can see that somehow my model has chaged the original quotation view (sale.view_order_form) into my view (work_order_form).

Somehow the quotation view (usually the same view as sale.order) has changed to the workorder view

A Sale Order (choose Order from Menu) is not affected.

I played around with the priority (changed it to higher or lower priorities) but that didn't really get a better result.

Can someone help and explain this strange behavior? Thanks


1
Avatar
Zrušit
Avatar
Sudhir Arya (ERP Harbor Consulting Services)
Nejlepší odpověď

If you inherit any view, basically the original view will have your changes as well and that is the use of inheritance.

In your case, you just don't want to show your custom fields to SO/Quotation menu and you can do it by hiding those custom fields from the original view/menu and just show them in your menu.

First, you should create a new action, add it in your menu and add something in the context of the action to show/hide the custom fields.

<record id="my_custom_action_orders" model="ir.actions.act_window">
<field name="name">Sales Orders</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.order</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="context">{'show_custom': True}</field>
</record>

Now, use the context value to show/hide the custom fields in your view as follow:

<xpath expr="//field[@name='partner_id']" position="after">
<field name="custom_field_1" invisible="not context.get('show_custom', False)"/>
<field name="custom_field_2" invisible="not context.get('show_custom', False)"/>
</xpath>

This way, your custom fields will be visible in your new menu (because the action context has "show_custom": True) and will be hidden in original views/menus.

I hope this will solve your problem.

6
Avatar
Zrušit
Kai Brossmann
Autor

Works perfect, thanks a lot.

One last question: Do I have to do this for each custom field or is there a way to apply ('show_custom' , False) to all my custom fields (I have quite a few) within that view.

Anyhow, I am very happy!

Sudhir Arya (ERP Harbor Consulting Services)

Happy to know this worked.

Yes, use the context to hide all your fields from other menus/views.

Avatar
Niyas Raphy (Walnut Software Solutions)
Nejlepší odpověď

Hi.

Either you can set the mode as primary and see, also give priority value greater than 16. See the below sample:

<record id="sale_onboarding_quotation_layout_form" model="ir.ui.view">
<field name="name">sale.onboarding.quotation.layout.form</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_document_template_form" />
<field name="mode">primary</field>
<field name="priority">1000</field>
<field name="arch" type="xml">
<xpath expr="//button[@special='save']" position="replace">
<button string="Apply" class="btn btn-primary" type="object" name="action_save_onboarding_quotation_layout" />
</xpath>
</field>
</record>

Thanks

1
Avatar
Zrušit
Kai Brossmann
Autor

Dear Niyas thank you for your answer. When I implement your solution I have two results. If I use eval="1000" non of the views (including my own) will display my custom fields. So I tried different priorities and found out that everything >20 will give me the same result. Only when I use eval="20" or smaller my custom fields will reappear. But, in this case, also in the Quotation view from the sale model. I also tend to think that the problem is somehow linked the action calling the wrong view. Why only the quotation action (and not also the Orders action) behaves like this?

Niyas Raphy (Walnut Software Solutions)

you can specify the views in corresponding menus, did you tried using mode primary ?

see this: https://www.youtube.com/watch?v=-2EAt9nN4o0

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 hiding a field
views inheritance
Avatar
Avatar
1
lis 24
2596
Change the Position of field in Xpath Vyřešeno
views inheritance
Avatar
Avatar
Avatar
Avatar
Avatar
5
čvc 24
95840
How to extend a base template for a specific page only, without affecting other pages that use the same base template?
views inheritance
Avatar
Avatar
1
pro 23
3998
removing elements from an inherited view
views inheritance
Avatar
Avatar
1
kvě 22
5027
I am building a custom module that has a dependent module that has extended the base view of res_partner. In my custom module I also have an inherited view of the base res_partner view. In it how do I hide the inherited view of my dependent module?
views inheritance
Avatar
0
led 20
3498
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