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

How to inherit list (tree) view?

Odebírat

Get notified when there's activity on this post

This question has been flagged
treeviewinherit
3 Odpovědi
16026 Zobrazení
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
Zrušit
Sehrish

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

Ingbert Jüdt
Autor

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
Nejlepší odpověď

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
Zrušit
Ingbert Jüdt
Autor

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
Autor

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
Autor

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
Autor Nejlepší odpověď
(Sorry, still confusing comments and answers)


1
Avatar
Zrušit
Avatar
Mrunal Gavali
Nejlepší odpověď

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
Zrušit
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!

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
How to create tree view of sibling models ? Vyřešeno
treeview inheritance inherit
Avatar
1
čvc 15
4544
How to Align Left [float, integer] Fields in Tree View in Odoo
treeview
Avatar
Avatar
Avatar
Avatar
3
dub 25
5915
How to do Prototpye inherit in odoo
inherit
Avatar
Avatar
Avatar
Avatar
Avatar
4
bře 24
4449
How to change column width in tree view one2many,many2many Vyřešeno
treeview
Avatar
Avatar
Avatar
Avatar
Avatar
5
lis 23
44356
Inheritance for account.financial.report model?
inherit
Avatar
Avatar
1
říj 23
6419
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