Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

How to inherit list (tree) view?

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
treeviewinherit
3 Risposte
16007 Visualizzazioni
Avatar
Ingbert Jüdt
I've got two models: Person, and Witness, which inherits from Person:

class Person(models.Model):
_name = 'ufodata.person'

first_name = fields.Char()
middle_name = fields.Char()
surname = fields.Char()
age = fields.Integer()
birthday = fields.Date()
obit = fields.Date()
gender = fields.Selection([
('male', 'Male'),
('female', 'Female'),
('other', 'Other')
], default="male", tracking=True)
addresses = fields.One2many('ufodata.address', 'resident', string='Addresses')

def name_get(self):
result = []
for record in self:
result.append((record.id, "%s %s %s" % (record.first_name, record.middle_name, record.surname)))
return result

class Witness(models.Model):
_name = 'ufodata.witness'
_inherit = {'ufodata.person'}
_rec_name = 'code_name'

code_name = fields.Char()
sightings = fields.Many2many('ufodata.sighting', 'sighting_witness_rel', string="Sightings")

I've got also two list views (I'll omit the form views, as inheriting them works fine):

<odoo>
<record id="view_tree_person" model="ir.ui.view">
<field name="name">Person List</field>
<field name="model">ufodata.person</field>
<field name="arch" type="xml">
<tree decoration-bf="first_name"
decoration-info="surname">
<field name="first_name" />
<field name="middle_name" />
<field name="surname" />
<field name="age" />
<field name="birthday" />
<field name="obit" />
<field name="gender" />
<field name="addresses" widget="many2many_tags" />
</tree>
</field>
</record>
</odoo>

<odoo>
<record id="view_tree_witness" model="ir.ui.view">
<field name="name">Witness List</field>
<field name="model">ufodata.witness</field>
<field name="inherit_id" ref="ufodata_app.view_tree_person" />
<field name="arch" type="xml">
<tree>
<field name="code_name" />
<field name="sightings" widget="many2many_tags" />
</tree>
</field>
</record>
</odoo>

Now inheriting the list view is NOT working.
(1) view_tree_witness will always show the "code_name" field in a column and nothing else.
(2) If I omit the "inherit_id" field entirely, inheritage will be assumed from the model and "code_name" is not found, producing an error
(3) The many2many field "sightings" is never shown
(4) If I add fields from the base view within the <tree> tag, they do not show up
<tree>
<field name="code_name" />
<field name="sightings" widget="many2many_tags" /> # not showing
<field name="first_name" /> # not showing
</tree>

To make it clear: none of these problems occur in form view, they are a tree view matter only. If I don't break the code entirely, I always
will have only one column in my view showing the code_name.

1
Avatar
Abbandona
Sehrish

Inheritance in models and views: https://goo.gl/4Zyc9d

Ingbert Jüdt
Autore

Thanks, but I'm already working with two of the three odoo books from packt, and if they tell what to do in my case, they hide it well.

Avatar
Zbik
Risposta migliore

Examples, first example add fields, next replace full tree:

<odoo>
<record id="view_tree_witness" model="ir.ui.view">
<field name="name">Witness List</field>
<field name="model">ufodata.witness</field>
<field name="inherit_id" ref="ufodata_app.view_tree_person" />
<field name="arch" type="xml">
<field name="addresses" position="after">
<field name="code_name" />
<field name="sightings" widget="many2many_tags" />
</field>
</field>
</record>
</odoo>


<odoo>
<record id="view_tree_witness" model="ir.ui.view">
<field name="name">Witness List</field>
<field name="model">ufodata.witness</field>
<field name="inherit_id" ref="ufodata_app.view_tree_person" />
<field name="arch" type="xml">
<tree position="replace">
<tree>
                <field name="code_name" />
<field name="sightings" widget="many2many_tags" />
<field name="first_name" />
                </tree>
           </tree>
</field>
</record>
</odoo>
PS. Probably you have problem with name field in sightings. How is defined ufodata.sighting?


2
Avatar
Abbandona
Ingbert Jüdt
Autore

Currently, I have a problem with updating my views ... as if the -u parameter of the odoo-bin cmd line would not work - have to deal with that problem first.

Ingbert Jüdt
Autore

I tried out both variants, but unfortunately neither makes a difference. The ONLY field that is shown in the tree view is "code_name", "sightings" is ignored, and also none of the base model/view fields shows up. Still have no idea what the problem could be.

Ingbert Jüdt
Autore

As for "sightings", model and view are defined as follows:

class Sighting(models.Model):

_name = 'ufodata.sighting'

_rec_name = 'identifier'

identifier = fields.Char()

description = fields.Text()

begin = fields.Datetime()

end = fields.Datetime()

location = fields.Char()

case = fields.Many2one('ufodata.case', string='Case')

investigator = fields.Many2one('ufodata.investigator', string='Investigator')

comments = fields.One2many('ufodata.sightingcomment', 'sighting', string='Comments')

witnesses = fields.Many2many('ufodata.witness', 'sighting_witness_rel', string="Witnesses")

<odoo>

<!-- FORM -->

<record id="view_form_sighting" model="ir.ui.view">

<field name="name">Sichtungen</field>

<field name="model">ufodata.sighting</field>

<field name="arch" type="xml">

<form string="Sightings">

<sheet>

<group>

<field name="identifier" />

<field name="description" />

<field name="begin" />

<field name="end" />

<field name="location" />

<field name="case" widget="many2one_tags" />

<field name="investigator" widget="many2one_tags" />

<field name="comments" widget="one2many_tags" />

<field name="witnesses" widget="many2many_tags" />

</group>

</sheet>

</form>

</field>

</record>

<!-- LIST -->

<record id="view_tree_sighting" model="ir.ui.view">

<field name="name">Sightings List</field>

<field name="model">ufodata.sighting</field>

<field name="arch" type="xml">

<tree decoration-bf="identifier">

<field name="identifier" />

<field name="description" />

<field name="begin" />

<field name="end" />

<field name="location" />

<field name="case" widget="many2one_tags" />

<field name="investigator" widget="many2one_tags" />

<field name="comments" widget="one2many_tags" />

<field name="witnesses" widget="many2many_tags" />

</tree>

</field>

</record>

<!-- KANBAN -->

<record id="view_kanban_sighting" model="ir.ui.view">

<field name="model">ufodata.sighting</field>

<field name="arch" type="xml">

<kanban>

<field name="case" />

<field name="identifier" />

<field name="description" />

<field name="begin" />

<field name="end" />

<field name="location" />

<templates>

<t t-name="kanban-box">

<div class="sighting_kanban_card">

<a type="open">

<field name="case" />

</a>

</div>

</t>

</templates>

</kanban>

</field>

</record>

</odoo>

Zbik

Review all views assigned to this model. You can delete them all and re-update the whole system with "-u all" parameters

Avatar
Ingbert Jüdt
Autore Risposta migliore
(Sorry, still confusing comments and answers)


1
Avatar
Abbandona
Avatar
Mrunal Gavali
Risposta migliore

Can anyone tell me

where is existing tree view id is located. i want to use to inherit new form which will locate in tree view.

0
Avatar
Abbandona
Satish Prajapati

Go to Tree view you want to inherit -> Click Debug button -> Edit View : List -> External ID

Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
How to create tree view of sibling models ? Risolto
treeview inheritance inherit
Avatar
1
lug 15
4541
How to Align Left [float, integer] Fields in Tree View in Odoo
treeview
Avatar
Avatar
Avatar
Avatar
3
apr 25
5903
How to do Prototpye inherit in odoo
inherit
Avatar
Avatar
Avatar
Avatar
Avatar
4
mar 24
4442
How to change column width in tree view one2many,many2many Risolto
treeview
Avatar
Avatar
Avatar
Avatar
Avatar
5
nov 23
44353
Inheritance for account.financial.report model?
inherit
Avatar
Avatar
1
ott 23
6418
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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