Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

How to inherit list (tree) view?

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
treeviewinherit
3 Replies
16024 Rodiniai
Portretas
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
Portretas
Atmesti
Sehrish

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

Ingbert Jüdt
Autorius

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.

Portretas
Zbik
Best Answer

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
Portretas
Atmesti
Ingbert Jüdt
Autorius

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
Autorius

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
Autorius

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

Portretas
Ingbert Jüdt
Autorius Best Answer
(Sorry, still confusing comments and answers)


1
Portretas
Atmesti
Portretas
Mrunal Gavali
Best Answer

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
Portretas
Atmesti
Satish Prajapati

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

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registracija
Related Posts Replies Rodiniai Veikla
How to create tree view of sibling models ? Solved
treeview inheritance inherit
Portretas
1
liep. 15
4544
How to Align Left [float, integer] Fields in Tree View in Odoo
treeview
Portretas
Portretas
Portretas
Portretas
3
bal. 25
5911
How to do Prototpye inherit in odoo
inherit
Portretas
Portretas
Portretas
Portretas
Portretas
4
kov. 24
4447
How to change column width in tree view one2many,many2many Solved
treeview
Portretas
Portretas
Portretas
Portretas
Portretas
5
lapkr. 23
44354
Inheritance for account.financial.report model?
inherit
Portretas
Portretas
1
spal. 23
6419
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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