コンテンツへスキップ
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 set this specific domain in XML?

購読

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

この質問にフラグが付けられました
domainxmlmany2oneodoo8.0
3 返信
39850 ビュー
アバター
Juan Formoso Vasco

I have the next table in Odoo, named relationship, which comes from the relation between the table girl and the table boy:

girl_id
boy_id
relationship_type
1
2
friends
1
3
siblings
2
7
lovers

So:

  • In the table girl there's a field relationships which is a one2many pointing to the table relationship.

  • In the table boy there's a field relationships which is a one2many pointing to the table relationship.

  • In the table relationship there are two fields, girl_id and boy_id, both pointing to the tables girl and boy respectively.

Scenario:

In the forms of girl and boy there's the field relationships. When I add a new relationship for a girl or a boy, a form is opened to fill in the fields of the table relationship (girl_id, boy_id and relationship_type). Imagine I'm in the form of a girl, I click on add a new relationship and the form is opened. I implemented this in order not to see the girl_id (it's invisible but it contains the ID of the current girl). So I can see only two fields (boy_id and relationship_type).

What I want:

Keeping on with the example, if I open the dropdown of boy_id, I'll see all boys, even the ones who are already related to this girl, and that's what I don't want. For example, if I'm adding a relationship to the girl with id 1, I must not see boys with ids 2 and 3, if the girl is the one with id 2, I must not see the boy with id 7.

My code:

<field name="girl_id" invisible="1"/>
<field name="boy_id" domain="[('id', 'not in', girl_id.relationships.boy_id)]"/> <!-- Obviously this does not work -->
<field name="relationship_type"/>

Can anyone help me, please? Thank you!

4
アバター
破棄
Temur

1) wrong domain, it should not work... 2) why do not use many2many relations between girl and boy? many2many relation seems more convenient to use in your scenario and all this packet of technical problems will disappear with it

Juan Formoso Vasco
著作者

Because it's my understanding that it's not possible to store more fields than the IDs in a many2many relationship, is it?

アバター
Temur
最善の回答

you can use relation many2many...

use in girl's model:

relationships = fields.Many2many(comodel_name="boy.model.name", relation='relation_table_name', column1='boy_id', column2='girl_id', string="relationships of this girl")


use in boy's model:

relationships = fields.Many2many(comodel_name="girl.model.name", relation='relation_table_name', column1='girl_id', column2='boy_id', string="relationships of this boy")


note that in both cases relation table is the same ( relation='relation_table_name' )

but column1 and column2 are inversed (in case of girl column1='boy_id' and column2='girl_id' but in case of boy column1='girl_id' and column2='boy_id'


UPDATE:

 apart of this two models, you can add new model and force it to have same table name as the relation table (using _table field):

_table = "relation_table_name"

and add the two fields representing ids:

boy_id = fields.Many2one(comodel_name="boy.model.name", string="Boy's ID")

girl_id = fields.Many2one(comodel_name="girl.model.name", string="Girl's ID")

also additional fields you like, as:

relationship_type = fields.Selection(....         (or fields.Char(... or something else...)

... 

you can find useful the last model.


OR


you can try to correct your domain as follows:

<field name="boy_id" domain="[('id', 'not in', the_computed_one2many_field )]"/>

add "the_computed_one2many_field" computed field and add it as invisible to the view.

the 'compute' function of "the_computed_one2many_field" must return list of ids...


probably the_computed_one2many_field may be also related field to girl_id.relationships.boy_id (not computed one)

0
アバター
破棄
Juan Formoso Vasco
著作者

Thank you for your help @Temur, but I think that way a boy will have the same relationship with every girl and the other way around. Let's imagine that I create the relationship_type on the table boy: when I create a boy, I will have to set the relationship type of that boy? And that boy will always have that relationship type!

Temur

yes, I see. I updated the answer. it's more complicated then I thought.

Juan Formoso Vasco
著作者

Thank you @Temur, I thought the last suggestion (after the OR) was the best and would work, but I get the RuntimeError: maximum recursion depth exceeded while calling a Python object, because there's a model with a one2many pointing to other model which also has a one2many pointing to the first one.

Temur

you tried to add computed field or related field?

Temur

lets say we're adding the computed field to girls model, then

@api.depends('girl_id')
def _compute_boys(self):
   #... implement the function

girls_relations = fields.One2many(comodel_name="boys.model.name", compute='_compute_boys')
for @api.depends I just guess, adapt it to your model. then use in xml:
<field name="boy_id" domain="[('id', 'not in', girls_relations )]"/>
and you'll need same for boy's relations...
Temur

probably @api.depends('relationships') and not girl_id ? I don't know your model structure

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

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

登録
関連投稿 返信 ビュー 活動
[SOLVED] Is posible change a domain_force in security.xml through a function in Python? (odoo 8) 解決済
security domain xml odoo8.0
アバター
アバター
2
3月 15
10914
Domain with inherited field 解決済
domain many2one
アバター
1
10月 22
4517
How to get the current user in XML
domain xml
アバター
アバター
アバター
2
11月 25
9967
Many2one field: 'id' instead of 'name' 解決済
many2one odoo8.0
アバター
アバター
1
2月 21
5599
Showing many2one fields in other modules 解決済
xml many2one
アバター
アバター
アバター
2
2月 18
13067
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • 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