コンテンツへスキップ
Odoo メニュー
  • サインイン
  • 無料で15日試す
  • アプリ
    財務
    • 会計
    • 請求
    • 経費
    • スプレッドシート(BI)
    • ドキュメント管理
    • 署名
    販売
    • CRM
    • 販売
    • POS店舗
    • POSレストラン
    • サブスクリプション
    • レンタル
    ウェブサイト
    • ウェブサイトビルダー
    • eコマース
    • ブログ
    • フォーラム
    • ライブチャット
    • eラーニング
    サプライチェーン
    • 在庫
    • 製造
    • 製品ライフサイクル管理 (PLM)
    • 購買
    • 整備
    • 品質
    人事業務
    • 従業員管理
    • 採用
    • 休暇管理
    • 人事評価
    • リファラル
    • フリート
    マーケティング
    • ソーシャルマーケティング
    • メールマーケティング
    • SMSマーケティング
    • イベント
    • マーケティングオートメーション
    • アンケート調査
    サービス
    • プロジェクト管理
    • タイムシート
    • フィールドサービス
    • ヘルプデスク
    • 計画
    • アポイントメント
    生産性向上ツール
    • ディスカッション
    • 承認
    • IoT
    • VoIP
    • ナレッジ
    • WhatsApp
    サードパーティアプリ Odooスタジオ Odooクラウドプラットホーム
  • インダストリー(業種別ソリューション)
    小売
    • 書店
    • アパレルショップ
    • 家具専門店
    • 食料品店
    • 金物店
    • 玩具店
    飲食・ホスピタリティ業界
    • バー・パブ
    • レストラン
    • ファストフード
    • ゲストハウス
    • 飲料販売代理店
    • ホテル
    不動産
    • 不動産会社
    • 建築事務所
    • 建設
    • 不動産管理
    • 造園
    • 住宅所有者組合
    コンサルティング
    • 会計事務所
    • Odooパートナー
    • マーケティングエージェンシー
    • 法律事務所
    • 人材派遣
    • 監査・認証
    製造
    • テキスタイル
    • 金属
    • 家具
    • 飲食
    • 醸造所
    • コーポレートギフト
    ヘルス & フィットネス
    • スポーツクラブ
    • 眼鏡店
    • フィットネスセンター
    • ウェルネス専門家
    • 薬局
    • ヘアサロン
    業種
    • 便利屋
    • IT ハードウェア・サポート
    • 太陽エネルギーシステム
    • 靴メーカー
    • クリーニングサービス
    • 空調設備サービス
    その他
    • 非営利団体
    • 環境機関
    • ビルボードレンタル
    • 写真
    • 自転車リース
    • ソフトウェアリセラー
    すべての業種を見る
  • コミュニティ
    学ぶ
    • チュートリアル
    • ドキュメンテーション
    • 認定
    • トレーニング
    • ブログ
    • ポッドキャスト
    教育サポート
    • 教育プログラム
    • Scale Up! ビジネスゲーム
    • Odooオフィス訪問
    ソフトを入手
    • ダウンロード
    • エディションを比較
    • リリース
    コラボレーション
    • Github
    • フォーラム
    • イベント
    • 翻訳
    • パートナーになる
    • パートナー様向けサービス
    • 会計事務所を登録
    サービス利用
    • パートナー一覧
    • 会計事務所一覧
    • 今すぐ相談する
    • 導入支援サービス
    • お客様一覧
    • サポート
    • アップグレード
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    製品デモを利用する
  • 料金
  • ヘルプ

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

  • CRM
  • e-Commerce
  • 会計
  • 在庫
  • PoS
  • プロジェクト
  • MRP
All apps
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
ヘルプ

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

購読

この投稿に活動があった際に通知を受け取ります

この質問にフラグが付けられました
treeviewmany2manyodoo8
1 返信
22748 ビュー
アバター
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
アバター
破棄
アバター
Denis Baranov
最善の回答

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
アバター
破棄
Pepiño
著作者

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
著作者

I have edited my original post to clarify my question.

Denis Baranov

I have added "Update" section in the answer

ディスカッションを楽しんでいますか?読むだけでなく、参加しましょう!

今すぐアカウントを作成して、限定機能を利用したり、素晴らしいコミュニティと交流しましょう!

登録
関連投稿 返信 ビュー 活動
Access many2many field from the other side
many2many odoo8
アバター
アバター
1
3月 15
6385
How can create a new button in the header of the tree view after the "create button or 'import' "? 解決済
treeview button odoo8
アバター
アバター
1
9月 18
13098
How to get url of a tree view with respect to its server and database
treeview url odoo8
アバター
0
10月 17
4287
How to show many2many_checkboxes in multiple columns? 解決済
many2many checkbox odoo8
アバター
アバター
アバター
2
9月 17
10928
many2many widget editable tree does not save changes?
treeview editable many2many
アバター
0
4月 17
4073
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • Github
  • Runbot
  • 翻訳
サービス
  • Odoo.shホスティング
  • サポート
  • アップグレード
  • カスタム開発
  • 教育プログラム
  • 会計事務所一覧
  • パートナー一覧
  • パートナーになる
企業情報
  • 会社概要
  • ブランドアセット
  • お問い合わせ
  • 採用情報
  • イベント
  • ポッドキャスト
  • ブログ
  • お客様一覧
  • リーガル情報 • プライバシーポリシー
  • セキュリティ
الْعَرَبيّة 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(オドゥー)は、CRM、eコマース、会計、在庫管理、POS、プロジェクト管理など、企業のさまざまな業務を一つのシステムで管理できる、ベルギー発のオープンソースのERPソフトウェアです。

高機能で使いやすく、完全に統合されたERPとして、ユニークな価値を提供しています。

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