Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Real Estate
    • Real Estate Agency
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consulting
    • Accounting Firm
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Solar Energy Systems
    • Shoe Maker
    • Serveis de neteja
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Views affect back on inherited views.

Subscriure's

Get notified when there's activity on this post

This question has been flagged
viewsinheritancesequencepriority
2 Respostes
6447 Vistes
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
Descartar
Avatar
Sudhir Arya (ERP Harbor Consulting Services)
Best Answer

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
Descartar
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)
Best Answer

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
Descartar
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!

Registrar-se
Related Posts Respostes Vistes Activitat
View inheritance hiding a field
views inheritance
Avatar
Avatar
1
de nov. 24
2569
Change the Position of field in Xpath Solved
views inheritance
Avatar
Avatar
Avatar
Avatar
Avatar
5
de jul. 24
95742
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
de des. 23
3983
removing elements from an inherited view
views inheritance
Avatar
Avatar
1
de maig 22
5009
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
de gen. 20
3488
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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