🛠️ OdooセキュリティRules
Odoo(オー・ドゥー)という
📺 まず動画で見る(YouTube)
▶ 【衝撃】最強のAIエージェント「Claude Code」の最新機能・使い方・プログラミングをAIで効率化する超実践術を解説! ↗
※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。
📜 元の英語説明(参考)
Expert in Odoo access control: ir.model.access.csv, record rules (ir.rule), groups, and multi-company security patterns.
🇯🇵 日本人クリエイター向け解説
Odoo(オー・ドゥー)という
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o odoo-security-rules.zip https://jpskill.com/download/3248.zip && unzip -o odoo-security-rules.zip && rm odoo-security-rules.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/3248.zip -OutFile "$d\odoo-security-rules.zip"; Expand-Archive "$d\odoo-security-rules.zip" -DestinationPath $d -Force; ri "$d\odoo-security-rules.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
odoo-security-rules.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
odoo-security-rulesフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-17
- 取得日時
- 2026-05-17
- 同梱ファイル
- 1
💬 こう話しかけるだけ — サンプルプロンプト
- › Odoo Security Rules を使って、最小構成のサンプルコードを示して
- › Odoo Security Rules の主な使い方と注意点を教えて
- › Odoo Security Rules を既存プロジェクトに組み込む方法を教えて
これをClaude Code に貼るだけで、このSkillが自動発動します。
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Odoo セキュリティルール
概要
Odoo のセキュリティは2つのレベルで管理されます。モデルレベルのアクセス(誰がどのモデルを読み書きできるか)とレコードレベルのルール(ユーザーがどのレコードを見ることができるか)です。このスキルは、正しい ir.model.access.csv エントリと ir.rule ドメインベースのレコードルールを作成するのに役立ちます。
このスキルを使用する場面
- 新しいカスタムモジュールのアクセス権を設定する場合。
- ユーザーが自分のデータまたは自分の会社のデータのみを表示するようにレコードを制限する場合。
- 「Access Denied」または「You are not allowed to access」エラーをデバッグする場合。
- マルチカンパニーのレコード可視性ルールを実装する場合。
仕組み
- アクティベート:
@odoo-security-rulesを記述し、アクセスシナリオを説明します。 - 生成: 正しい CSV アクセス行と XML レコードルールを取得します。
- デバッグ: アクセスエラーを貼り付け、修正を含む診断を取得します。
例
例 1: ir.model.access.csv
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_hospital_patient_user,hospital.patient.user,model_hospital_patient,base.group_user,1,0,0,0
access_hospital_patient_manager,hospital.patient.manager,model_hospital_patient,base.group_erp_manager,1,1,1,1
注: ERP マネージャーには
base.group_erp_managerを使用し、base.group_systemは使用しないでください。このグループは Odoo の技術的なスーパーユーザーのために予約されています。モジュール固有のマネージャーロールには、常にカスタムグループを作成してください。<record id="group_hospital_manager" model="res.groups"> <field name="name">Hospital Manager</field> <field name="category_id" ref="base.module_category_hidden"/> </record>
例 2: レコードルール — ユーザーは自分のレコードのみを表示
<record id="rule_hospital_patient_own" model="ir.rule">
<field name="name">Hospital Patient: Own Records Only</field>
<field name="model_id" ref="model_hospital_patient"/>
<field name="domain_force">[('create_uid', '=', user.id)]</field>
<field name="groups" eval="[(4, ref('base.group_user'))]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_unlink" eval="False"/>
</record>
重要:
<field name="groups">を省略すると、ルールはグローバルになり、管理者を含むすべてのユーザーに適用されます。グローバルな制限を明示的に意図しない限り、常にグループを割り当ててください。
例 3: マルチカンパニーレコードルール
<record id="rule_hospital_patient_company" model="ir.rule">
<field name="name">Hospital Patient: Multi-Company</field>
<field name="model_id" ref="model_hospital_patient"/>
<field name="domain_force">
['|', ('company_id', '=', False),
('company_id', 'in', company_ids)]
</field>
<field name="groups" eval="[(4, ref('base.group_user'))]"/>
</record>
ベストプラクティス
- ✅ すべきこと: 最も制限の厳しいアクセスから始め、必要に応じて開放してください。
- ✅ すべきこと: マルチカンパニーのルールでは
company_ids(複数形) を使用してください。これはユーザーが所属するすべての会社を含みます。 - ✅ すべきこと: デバッグモードで非管理者ユーザーを使用してルールをテストしてください。
sudo()はすべてのレコードルールを完全にバイパスします。 - ✅ すべきこと: コア Odoo グループを再利用するのではなく、モジュールごとに専用のセキュリティグループを作成してください。
- ❌ すべきでないこと: 業務プロセスで削除が明示的に必要でない限り、一般ユーザーに
perm_unlink = 1を与えないでください。 - ❌ すべきでないこと: 公開(認証されていない)アクセスを許可する意図がない限り、
ir.model.access.csvでgroup_idを空白にしないでください。 - ❌ すべきでないこと: モジュールマネージャーに
base.group_systemを使用しないでください。これはサーバー設定を含む完全な技術的アクセスを許可します。
制限事項
- フィールドレベルのアクセス制御(
ir.model.fieldsの読み書き制限)は対象外です。これらにはカスタムの OWL または Python のオーバーライドが必要です。 - ポータルおよび公開ユーザーのアクセスルールには、ここで完全にカバーされていない追加のニュアンスがあります。
base.group_portalを使用して慎重にテストしてください。 - レコードルールは
sudo()によってバイパスされます。スーパーユーザーコンテキストで実行されるコードは、すべてのir.ruleエントリを無視します。 - PostgreSQL を介した行レベルセキュリティ(RLS)は対象外です。Odoo はすべてのセキュリティを ORM レイヤーで管理します。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Odoo Security Rules
Overview
Security in Odoo is managed at two levels: model-level access (who can read/write which models) and record-level rules (which records a user can see). This skill helps you write correct ir.model.access.csv entries and ir.rule domain-based record rules.
When to Use This Skill
- Setting up access rights for a new custom module.
- Restricting records so users only see their own data or their company's data.
- Debugging "Access Denied" or "You are not allowed to access" errors.
- Implementing multi-company record visibility rules.
How It Works
- Activate: Mention
@odoo-security-rulesand describe the access scenario. - Generate: Get correct CSV access lines and XML record rules.
- Debug: Paste an access error and get a diagnosis with the fix.
Examples
Example 1: ir.model.access.csv
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_hospital_patient_user,hospital.patient.user,model_hospital_patient,base.group_user,1,0,0,0
access_hospital_patient_manager,hospital.patient.manager,model_hospital_patient,base.group_erp_manager,1,1,1,1
Note: Use
base.group_erp_managerfor ERP managers, notbase.group_system— that group is reserved for Odoo's technical superusers. Always create a custom group for module-specific manager roles:<record id="group_hospital_manager" model="res.groups"> <field name="name">Hospital Manager</field> <field name="category_id" ref="base.module_category_hidden"/> </record>
Example 2: Record Rule — Users See Only Their Own Records
<record id="rule_hospital_patient_own" model="ir.rule">
<field name="name">Hospital Patient: Own Records Only</field>
<field name="model_id" ref="model_hospital_patient"/>
<field name="domain_force">[('create_uid', '=', user.id)]</field>
<field name="groups" eval="[(4, ref('base.group_user'))]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_unlink" eval="False"/>
</record>
Important: If you omit
<field name="groups">, the rule becomes global and applies to ALL users, including admins. Always assign a group unless you explicitly intend a global restriction.
Example 3: Multi-Company Record Rule
<record id="rule_hospital_patient_company" model="ir.rule">
<field name="name">Hospital Patient: Multi-Company</field>
<field name="model_id" ref="model_hospital_patient"/>
<field name="domain_force">
['|', ('company_id', '=', False),
('company_id', 'in', company_ids)]
</field>
<field name="groups" eval="[(4, ref('base.group_user'))]"/>
</record>
Best Practices
- ✅ Do: Start with the most restrictive access and open up as needed.
- ✅ Do: Use
company_ids(plural) in multi-company rules — it includes all companies the user belongs to. - ✅ Do: Test rules using a non-admin user in debug mode —
sudo()bypasses all record rules entirely. - ✅ Do: Create dedicated security groups per module rather than reusing core Odoo groups.
- ❌ Don't: Give
perm_unlink = 1to regular users unless deletion is explicitly required by the business process. - ❌ Don't: Leave
group_idblank inir.model.access.csvunless you intend to grant public (unauthenticated) access. - ❌ Don't: Use
base.group_systemfor module managers — that grants full technical access including server configurations.
Limitations
- Does not cover field-level access control (
ir.model.fieldsread/write restrictions) — those require custom OWL or Python overrides. - Portal and public user access rules have additional nuances not fully covered here; test carefully with
base.group_portal. - Record rules are bypassed by
sudo()— any code running in superuser context ignores allir.ruleentries. - Does not cover row-level security via PostgreSQL (RLS) — Odoo manages all security at the ORM layer.