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
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • 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
    Procházet všechna odvětví
  • 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
    • Služby pro partnery
    • 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

Odoo 8 - Many2Many field in a tree view, how to show it in two o more columns?

Odebírat

Get notified when there's activity on this post

This question has been flagged
treeviewmany2manyodoo8
1 Odpovědět
22830 Zobrazení
Avatar
Pepiño

Hi Odoo developers,

I would want to show a many2many field from a module in its tree view but splitted in columns. Here is my example.

I have a TodoTask model with a field named tag_ids (a task may have multiple tags).

class TodoTask(models.Model):
_inherit = 'todo.task'
# Relational fields
stage_id = fields.Many2one('todo.task.stage', 'Stage')
tag_ids = fields.Many2many(
'todo.task.tag', # related= (model name)
'todo_task_tag_rel', # relation= (table name)
'task_id', # column1= ("this" field)
'tag_id', # column2= ("other" field)
string='Tags',
# Relational field attributes:
auto_join=False,
context="{}",
domain="[]",
ondelete='cascade',
)

The Tag model:

class Tag(models.Model):
_name = 'todo.task.tag'
name = fields.Char('Name', size=40, translate=True)
# Many2many inverse relation
task_ids = fields.Many2many('todo.task', string='Tasks')
# Hierarchic relations:
_parent_store = True
_parent_name = 'parent_id' # the default
parent_id = fields.Many2one(
'todo.task.tag', 'Parent Tag', ondelete='restrict')
parent_left = fields.Integer('Parent Left', index=True)
parent_right = fields.Integer('Parent Right', index=True)
child_ids = fields.One2many('todo.task.tag', 'parent_id', 'Child Tags')

The tree view associated to TodoTask model:

<record id="todo_app.view_tree_todo_task" model="ir.ui.view">
<field name="name">To-do Task Tree</field>
<field name="model">todo.task</field>
<field name="arch" type="xml">
<tree colors="gray:is_done==True"
font="italic:stage_state!='open'"
delete="false">
<field name="is_done" invisible="True"/>
<field name="stage_state" invisible="True"/>
<field name="name"/>
<field name="tag_ids"/>
</tree>
</field>
</record>

The most important part of the above view is field name="tag_ids".
tag_ids is a Many2Many field in TodoTask model (todo.task) related to Tag model (todo.task.tag).

The problem is that this tree view shows only one column for tag_ids (see column Tags in the next image).


 http://i.imgur.com/G44hQh4.png

I would like to show the Many2Many field (tag_ids) from TodoTask model in more than one column in the tree view associated to TodoTask model: one column for tag name, another column for another field from Tag model, ...

nameCourse | start_date Course | tag name | tag parent name |
------------------------------------------------------------------------------------
course 1         2015-5-15                 tag1          tag2
course 1         2015-5-15                 tag3          tag2

 

0
Avatar
Zrušit
Avatar
Denis Baranov
Nejlepší odpověď

Update

I got your point. It is impossible to do it by standard instrument, you will have to change the widget (a lot of work by modifying javascript). Basically, there can't be table inside table in xml Odoo at the moment.

The only solution which I can see:

1) To modify display_name field (name_get in OpenERP 7), in order it will show all necessary data. For example:

        @api.one
        @api.depends('name', 'ref ')
        def _get_display_name(self):
            self.display_name = name + ref
        
display_name = fields.Char(string='Name', compute='_get_display_name',) name = fields.Char(string='Name') ref = fields.Char(string='Ref')

2) To use widget many2many_tags inside column of tags.

You also may try to add intermediary class, which will consists of: 1. class_x fields (inherits from this class), 2. tag as M2O field, 3. tag fields as related fields. Then you will have a tree with all the columns.

Initial answer

If I understood you in a right way, you would like to add columns from todo.task.tag model. If so, everything you need is to add tree inside tag_ids. E.g.: 

<field name="tag_ids"> <tree> <field name='name '/> <field name='parent_id '/> </tree> </field>


0
Avatar
Zrušit
Pepiño
Autor

Your solution doesn't work in a tree view, only in a form view. I want to show different columns in a tree view for a many2many field. model Course(models.Model): name = fields.Char(string='Name Course') max_seats = fields.Integer() start_date = fields.DateTime() tag_ids = fields.Many2many('todo.task.tag') model Tag(models.Model): _name="todo.task.tag" name = fields.Char() quality = fields.Integer() In the Course's form view, I want to show two columns for the tag_ids field: name and quality: -------------------------------------------------------------------------------------------------- Name Course | max_seats | start_date | name (tag_ids) | quality (tag_ids) | -------------------------------------------------------------------------------------------------- course 1 25 2015-5-5 tag1 25 course 2 70 2015-5-6 tag2 35

Pepiño
Autor

I have edited my original post to clarify my question.

Denis Baranov

I have added "Update" section in the answer

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
Access many2many field from the other side
many2many odoo8
Avatar
Avatar
1
bře 15
6452
How can create a new button in the header of the tree view after the "create button or 'import' "? Vyřešeno
treeview button odoo8
Avatar
Avatar
1
zář 18
13158
How to get url of a tree view with respect to its server and database
treeview url odoo8
Avatar
0
říj 17
4326
How to show many2many_checkboxes in multiple columns? Vyřešeno
many2many checkbox odoo8
Avatar
Avatar
Avatar
2
zář 17
11017
many2many widget editable tree does not save changes?
treeview editable many2many
Avatar
0
dub 17
4131
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