コンテンツへスキップ
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 Record Rule with domain based on the company_dependent Fields

購読

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

この質問にフラグが付けられました
odoo12.0
3 返信
10796 ビュー
アバター
Mohammed Zubair

I want to write a record rule with domain based on the company_dependent fields (means that field value is storing in ir.property Model). 

Means, I have one field i.e. x_company_dependent_field in product.category Model and I want to write one record rule in product. In record-rule domain, I want to compare the product.category fields value with the User fields i.e. x_any_field (normal field).



so that domain can be like below.

Like(domain),  [('categ_id.x_company_dependent_field', '=', user.x_any_field)]


I have tried with same but not working.

But when I am giving 'False' value then showing me products.


Like,  [('categ_id.x_company_dependent_field', '=', False)]


How can we handle this part ?

odoo12

Thanks in advance

0
アバター
破棄
アバター
Mohammed Zubair
著作者 最善の回答

I got the problem area for record-rule on company-dependent fields in multi-company case.

When we work with multi-company scenario that means if user logged into their account system should show his company in code i.e. self.env.user.company_id. Instead of this everytime system takes ADMIN(2) user company.

So that record-rule does not satisfied.

Problem-statement

Followings are the output from odoo files.

file: odoo/models.py [def _search(). line-4130]

Working-Condiiton with Main Company

When I login with the current company then query prepare with proper product.category company dependent fields. In this condition domain is properly taking main company id i.e. 3.

below is final query :

auto-prepared domain: ir.property() -->[('fields_id', '=', 10385), ('company_id', 'in', [3, False]), ('value_reference', 'in', ['x_business_team,2', 'x_business_team,5'])] 

ir.property query

 <osv.Query: "SELECT ... FROM "ir_property" WHERE ((("ir_property"."fields_id" = %s)  AND  (("ir_property"."company_id" in (%s)) OR "ir_property"."company_id" IS NULL))  AND  ("ir_property"."value_reference" in (%s,%s)))" with params: [10385, 3, 'x_business_team,2', 'x_business_team,5']>

Query:

<osv.Query: "SELECT ... FROM "product_category" WHERE ("product_category"."id" in (%s,%s,%s,%s,%s,%s,%s,%s))" with params: [14, 15, 16, 17, 18, 64, 40, 71]>


we can see, quer is taking product.category proper id based on the company-dependent fields i.e. from ir.property

SELECT count(1) FROM "product_template" LEFT JOIN 

                (SELECT res_id, value FROM "ir_translation"

                 WHERE type='model' AND name=%s AND lang=%s AND value!='')

             as "product_template__name" ON ("product_template"."id" = "product_template__name"."res_id") WHERE (("product_template"."active" = %s)  AND  ("product_template"."type" in (%s,%s))) AND ((((("product_template"."company_id" in (%s,%s))  OR  ("product_template"."company_id" in (%s)))  OR  "product_template"."company_id" IS NULL )  OR  ("product_template"."id" in (SELECT "product_template_id" FROM "x_product_template_res_partner_rel" WHERE "res_partner_id" IN %s)))  AND  ("product_template"."categ_id" in (%s,%s,%s,%s,%s,%s,%s,%s))) ['product.template,name', 'en_US', True, 'consu', 'product', 3, 1, 3, (8,), 14, 64, 15, 16, 17, 18, 71, 40]


Not working-condition with other company

When I login with the other company then query prepare with product.category company dependent fields as FALSE condition. Because in condition domain, we can see its taking main company i.e. id=3 but current company is 10.

auto-prepared domain:  ir.property() [('fields_id', '=', 10385), ('company_id', 'in', [3, False]), ('value_reference', 'in', ['x_business_team,33'])]

ir.property query

"SELECT ... FROM "ir_property" WHERE ((("ir_property"."fields_id" = %s)  AND  (("ir_property"."company_id" in (%s)) OR "ir_property"."company_id" IS NULL))  AND  ("ir_property"."value_reference" in (%s)))" with params: [10385, 3, 'x_business_team,33']>

Query

<osv.Query: "SELECT ... FROM "product_category" WHERE FALSE" with params: []>

But here is coming as False.


SELECT count(1) FROM "product_template" LEFT JOIN 

                (SELECT res_id, value FROM "ir_translation"

                 WHERE type='model' AND name=%s AND lang=%s AND value!='')

             as "product_template__name" ON ("product_template"."id" = "product_template__name"."res_id") 

WHERE ("product_product"."active" = %s) AND ("product_product"."product_tmpl_id"="product_product__product_tmpl_id"."id") AND (FALSE  AND  ("product_product__product_tmpl_id"."categ_id" in (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s))) AND ((((("product_product__product_tmpl_id"."company_id" in (%s,%s))  OR  ("product_product__product_tmpl_id"."company_id" in (%s)))  OR  "product_product__product_tmpl_id"."company_id" IS NULL )  OR  ("product_product__product_tmpl_id"."id" in (SELECT "product_template_id" FROM "x_product_template_res_partner_rel" WHERE "res_partner_id" IN %s)))  AND  FALSE)


That means, because of the company comparison it is not taking product.category company-dependent fields value from ir.property model.


Solutions

In ir.rule model, method: def domain_get(), we can make self as current company after check 'force_company' not in self.env.context. by using,

self = self.with_context({'force_company': self.env.user.company_id.id})

then call super method.

In ir.rule model, method: def _compute_domain_keys(), we can append 'force_company' in returned list after super method call.

res.append('force_company')


working query:

its taking proper company i.e. 10 in domain

ir.property query:

 ir.property() [('fields_id', '=', 10385), ('company_id', 'in', [10, False]), ('value_reference', 'in', ['x_business_team,33', 'x_business_team,34'])]


<osv.Query: "SELECT ... FROM "ir_property" WHERE ((("ir_property"."fields_id" = %s)  AND  (("ir_property"."company_id" in (%s)) OR "ir_property"."company_id" IS NULL))  AND  ("ir_property"."value_reference" in (%s,%s)))" with params: [10385, 10, 'x_business_team,33', 'x_business_team,34']>

<osv.Query: "SELECT ... FROM "ir_property" WHERE ((("ir_property"."fields_id" = %s)  AND  (("ir_property"."company_id" in (%s)) OR "ir_property"."company_id" IS NULL))  AND  ("ir_property"."value_reference" in (%s,%s)))" with params: [10385, 10, 'x_business_team,33', 'x_business_team,34']>


product.category query:

<osv.Query: "SELECT ... FROM "product_category" WHERE ("product_category"."id" in (%s,%s,%s))" with params: [70, 71, 72]>


main query:

SELECT count(1) FROM "product_template" LEFT JOIN 

                (SELECT res_id, value FROM "ir_translation"

                 WHERE type='model' AND name=%s AND lang=%s AND value!='')

             as "product_template__name" ON ("product_template"."id" = "product_template__name"."res_id") WHERE (("product_template"."active" = %s)  AND  ("product_template"."type" in (%s,%s))) AND ((((("product_template"."company_id" in (%s,%s))  OR  ("product_template"."company_id" in (%s)))  OR  "product_template"."company_id" IS NULL )  OR  ("product_template"."id" in (SELECT "product_template_id" FROM "x_product_template_res_partner_rel" WHERE "res_partner_id" IN %s)))  AND  (("product_template"."categ_id" in (%s,%s,%s))  AND  (("product_template"."categ_id" in (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s))  OR  ("product_template"."categ_id" in (%s,%s,%s))))) ['product.template,name', 'en_US', True, 'consu', 'product', 10, 1, 10, (6662,), 70, 71, 72, 38, 39, 1, 56, 3, 14, 65, 79, 80, 81, 64, 15, 16, 17, 18, 86, 70, 71, 72, 82, 83, 84, 76, 77, 78, 66, 68, 67, 85, 73, 74, 75, 40, 41, 42, 43, 44, 57, 45, 46, 48, 49, 50, 51, 52, 55, 53, 54, 47, 70, 71, 72]

0
アバター
破棄
アバター
Adil Akbar
最善の回答

Hi, 

You can see following for this:

https://youtu.be/GkNgc-fZO-I

Hope it helps,

Thanks

0
アバター
破棄
アバター
Jaga
最善の回答

Try this example :           

self.write({'list_price': value})

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

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

登録
関連投稿 返信 ビュー 活動
Expected singleton: hr.emp.travel.location(62, 63)
odoo12.0
アバター
アバター
アバター
2
10月 25
2006
loan request
odoo12.0
アバター
アバター
1
9月 23
4038
sum Colum of based on id
odoo12.0
アバター
アバター
1
5月 23
3013
How to make pagination that has a table in qweb
odoo12.0
アバター
アバター
2
4月 23
3762
Inherit Element form kanban View 解決済
odoo12.0
アバター
アバター
1
3月 23
2914
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • 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