コンテンツへスキップ
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
このフォーラムについて
ヘルプ

How to write this domain for a one2many field on a view?

購読

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

この質問にフラグが付けられました
domainformviewmany2oneone2many
3 返信
27271 ビュー
アバター
Pascal Tremblay

Hello guys!

I really have problem with domain for one2many field.

In the res.company form, I select some partners for the field line_of_business_ids. I save this and it works.

In the view view_partner_property_form (see below) the field line_business_ids of the partner should only offer the values available in the field line_of_business_ids of his own and only company_id. Every partner has a company_id field. And any company has a line_of_business_ids field (in my case). 

I'm not able to write this domain myself.

Could you help me?

Thanks to help

I actually have this code :

In Python

class Partner(models.Model):
_inherit = "res.partner"
     related_business_id = fields.Many2one('res.partner', string='Related business line')
     line_business_ids = fields.One2many(comodel_name='res.partner', inverse_name='related_business_id')

class res_company(models.Model):
_inherit = "res.company"
     line_of_business_ids = fields.Many2many(comodel_name='res.partner')

In the xml view

<record id="view_partner_property_form" model="ir.ui.view">
    <field name="name">base.view.partner.form.inherit.vtm2</field>
     <field name="model">res.partner</field>
     <field name="inherit_id" ref="base.view_partner_form" />
     <field name="arch" type="xml">
         <field name="category_id" position="after">
            <field name="line_business_ids" widget="many2many_tags"
                attrs="{'invisible': [('is_company','=', False)]}"
                options="{'no_create_edit': True}"
                domain="[('id', 'in', 'company_id.line_of_business_ids.ids')]" />
        </field>
    </field>
</record>


See image of the situation



Edit #1

I have tried all this domains. No success...

domain="[('company_id.line_of_business_ids', 'in', id )]"

domain="[('id', 'in', company_id.line_of_business_ids)]

domain="[ ( 'company_id.line_of_business_ids', '=', [ (6, [0], [id]) ] ) ]

domain="[('company_id.line_of_business_ids.id', 'in', company_id.line_of_business_ids )]"

domain="[('company_id.line_of_business_ids', '=', company_id.line_of_business_ids.ids )]"

domain="[('company_id.line_of_business_ids', '=', company_id.line_of_business_ids.id )]"

domain="[('company_id.line_of_business_ids', '=', company_id.line_of_business_ids.partner_id.id )]"

domain="[('company_id.line_of_business_ids', 'in', company_id.line_of_business_ids )]"

domain="[('company_id.line_of_business_ids', 'in', company_id.line_of_business_ids[0][2] )]"


1
アバター
破棄
アバター
Akhil P Sivan
最善の回答

Hi, 

Pardon me if I misunderstood your requirement. But please clarify the following.

Why can't you use a related One2many field on res.partner to company_id.line_of_business_ids, which could be a readonly field. Since a partner is supposed to have only one company_id, I think no need to use a Many2many field in res.company, you could have use a One2many field. For related fields, both field types should be same.

Then on the partner form, in line_business_ids you can only see the partners added on his company.

For eg:

class Partner(models.Model):
    _inherit = "res.partner"
    line_business_ids = fields.One2many(related='company_id.line_of_business_ids', readonly=True, string="Line business ids")

class res_company(models.Model):
    _inherit = "res.company"
    line_of_business_ids = fields.One2many('res.partner','company_id',string="Line of business ids")
3
アバター
破棄
Pascal Tremblay
著作者

Mister Sivan, I want to send you 1000 thanks for this precious answer. I will publish my solution soon.

A chance you have been there!

Akhil P Sivan

Good to know that my answer helps you :)

アバター
Pascal Tremblay
著作者 最善の回答

Big thanks to mister Sivan for his help. It was precious!

Here is our complete solution

In Python, with more significant names

class Partner(models.Model):
    _inherit = "res.partner"

    customer_of_division_id = fields.Many2one(comodel_name='res.partner', domain="[('division_of_company_id','=',company_id)]", string='Customer of the division')
    division_of_company_id = fields.Many2one('res.company', string='Division of the company')

class res_company(models.Model):
    _inherit = "res.company"
   
    division_ids = fields.One2many('res.partner','division_of_company_id', string="Divisions of this company")


In views

<record id="view_company_form" model="ir.ui.view">
            <field name="name">base.view.company.form.inherited.vtm2</field>
            <field name="model">res.company</field>
            <field name="inherit_id" ref="base.view_company_form" />
            <field name="arch" type="xml">
                <field name="website" position="after">
                    <field name="division_ids" widget="many2many_tags" string="Divisions of this company" />
                </field>
            </field>
</record>


<record id="view_partner_property_form_inherit" model="ir.ui.view">
            <field name="name">base.view.partner.form.inherit.vtm2</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form" />
            <field name="arch" type="xml">
                <field name="category_id" position="after">
                      <field name="customer_of_division_id" />
                    <field name="division_of_company_id" />
               </field>
            </field>
</record>


In images






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

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

登録
関連投稿 返信 ビュー 活動
domain in many2one that in One2many field 解決済
domain many2one one2many
アバター
1
10月 22
4016
Don't show equipment more than once
domain many2one one2many
アバター
アバター
1
8月 19
3089
Odoo 9: Set domain for field in One2many
domain many2one one2many
アバター
アバター
1
9月 17
5962
Display One2many field multiple time in same form 解決済
domain form one2many
アバター
アバター
1
8月 16
9551
Why is my many2one field not displayed the same way at this two places? 解決済
address form view many2one
アバター
アバター
5
2月 17
6563
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • 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