Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Guest House
    • Drankenhandelaar
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Solar Energy Systems
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC Services
    Others
    • Nonprofit Organization
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

Inheriting a view without overriding the original view [SOLVED]

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
viewsinheritanceoverrideodoo8
5 Antwoorden
58868 Weergaven
Avatar
Pepiño

Hi Odoo developers,

I would like to create a view inheriting from another view to remove some elements by using xpath expressions, but I don't want to modify the original view.

The view's code:

    <record model="ir.ui.view" id="email_compose_message_wizard_form2">
<field name="name">mi_new_view</field>
<field name="model">mail.compose.message</field>
<field name="inherit_id" ref="mail.email_compose_message_wizard_form"/>
<field name="arch" type="xml">
<xpath expr="//span[contains(.,'Followers of the document and')]"
position="replace"/>
</field>
</record>

The original view is "mail.email_compose_message_wizard_form".

My view inherits from the "mail.email_compose_message_wizard_form" view, deleting one span element.
I need that my view has all the elements from the original view except one span element.

The problem is that this span element is also deleted from the original view, and I don't want to get this.

How can I achieve this without modifying the original view?.

Thanks for your help.

EDIT (THE SOLUTION):

Thanks to Pedro Manuel Baeza for your solution in the openerp-span google group (https://groups.google.com/forum/#!topic/openerp-spain/ndfXfeFihjA)

The solution is to add 

<field name="mode">primary</field> 

in the inheriting view:

    <record model="ir.ui.view" id="email_compose_message_wizard_form2">
<field name="name">mi_new_view</field>
<field name="model">mail.compose.message</field>
<field name="inherit_id" ref="mail.email_compose_message_wizard_form"/>
<field name="mode">primary</field>
<field name="arch" type="xml">
<xpath expr="//span[contains(.,'Followers of the document and')]"
position="replace"/>
</field>
</record>

12
Avatar
Annuleer
Avatar
Niyas Raphy (Walnut Software Solutions)
Beste antwoord

Hi,

For this you just need to inherit the original view and set the mode as primary , which will be a working as a new view from the inherited view, along with the changes applied here.

Sample:

<record id="ir_cron_view_form" model="ir.ui.view">
<field name="name">ir.cron.view.form</field>
<field name="model">ir.cron</field>
<field name="mode">primary</field>
<field name="inherit_id" ref="base.view_server_action_form"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='create_action']" position="replace">
<button name="method_direct_trigger" type="object" string="Run Manually" class="oe_highlight" attrs="{'invisible': [('state', '!=', 'code')]}"/>
</xpath>
</field>
</record>

Reference:

  1. How To Inherit And Create New Report In Odoo

  2. Apply Changes In A View For Particular User Groups In Odoo

  3. How To Inherit Views

Thanks

3
Avatar
Annuleer
Avatar
Herbert Van de Poel
Beste antwoord

For those non-developers out there, this is the way I solve this in Odoo online v15 without XML or dev skills:

Let's say I have a view A (standard Odoo view), and I want to create a new view B building on top of A.

To achieve the desired outcome where View B is modified based on View A without altering View A, you should select "Base View" in the "View Inheritance Mode" when using the Odoo configuration menu to duplicate the view.

Here's the correct process:

  1. Go to "Settings" in the main menu of Odoo.

  2. Under the "Technical" section, click on "Views" to access the view configuration.

  3. Locate View A in the list of views and click on it to open the view configuration form.

  4. In the form, click on the "Duplicate" button (or a similar option) to create a duplicate of View A.

  5. Modify the necessary details of the duplicated view, such as the name and any other attributes specific to View B.

  6. In the "View Inheritance Mode" field, select "Base View" from the dropdown menu.

By selecting "Base View" as the view inheritance mode, you indicate that View B is based on View A and any modifications made to View B will not alter View A.

  1. Save the changes.

Following these steps, you have created View B based on View A using the duplication feature in the Odoo configuration menu. The "Base View" inheritance mode ensures that any modifications made to View B will not affect View A.


2
Avatar
Annuleer
Anton

When changing to "Base View", which view form do i have to set this? in View A? Because when i set it to View B, it didn't work.

Avatar
Emipro Technologies Pvt. Ltd.
Beste antwoord

Hi,

To achieve your goal that inherit one view and do not want to change in base view then you have to define new view of the same object without inherit any other view. If you have perform inheritance then base view will always be changed.

So, just make your own new view and set it inside your menu/action. thats it.


0
Avatar
Annuleer
Pepiño
Auteur

Thanks for your answer, but what I want is not to have the same code of the view repeated two times: in the base view and the inheriting view. I only want to delete one element from the base view in my inheriting view without repeating the same xml code. It is the 'don't repeat yourself' principle. But I'm not sure whether this is possible in Odoo.

Avatar
Sehrish
Beste antwoord

In Odoo/OpenERP we can inherit or use existing modules object/class/model and views. We can also inherit single field of existing modules. The question is why we need such inheritance.

The purpose of inheritance or why we need inheritance is given below:

  1. To change attributes of some fields which exists on existing/custom model (e.g. making fields readonly,invisible)

  2. To add/modify/delete old or new fields in existing/custom model (e.g. Product, Sales, HR, Fleet Management, Attendance modules model etc)

  3. We can also add buttons in already existing/custom model (form and tree) view by using inheritance

Models.py

class groups(models.Model):
 _inherit = 'res.groups'
 # we inherited res.groups model which is Odoo/OpenERP built in model and created two fields in that model.
 field_1 = fields.Char(required=True,string="Field One")
 field_2 = fields.Boolean(default=False,string="Field Two") 

XML

    
        
            res.group.form.view.inherited
            res.groups
            
            
            
            

                
                    
                                
                
                
                    
                        

                                           
        
    
  

You can get more detail about inheritance from below link:

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

0
Avatar
Annuleer
Avatar
Ahmed Badawi
Beste antwoord

how u solved it ?

0
Avatar
Annuleer
Ahmed Badawi

thanks - soulation under your question

Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
View inheritance hiding a field
views inheritance
Avatar
Avatar
1
nov. 24
2561
Change the Position of field in Xpath Opgelost
views inheritance
Avatar
Avatar
Avatar
Avatar
Avatar
5
jul. 24
95719
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
dec. 23
3973
removing elements from an inherited view
views inheritance
Avatar
Avatar
1
mei 22
4998
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
jan. 20
3485
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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