Creating Validation Rules

Updated 8 October 2026

Learn all 10 rule types and how to configure checks that protect your data quality.

Overview

A Validation Rule is a single data-checking instruction. It defines what to check, when to check it, and what happens if the check fails. Rules are the building blocks of your data quality system.

Each rule targets a specific model (like Contacts or Sales Orders) and can either Block Save or show a Warning Only.

How It Works

When a user creates, edits, deletes, or changes the status of a record, Odoo runs all active rules that match the model, trigger, user group, and company. If a rule fails:

Step-by-Step Guide

Rule Types

Rule Configuration Fields

Field Explanations

Trigger

Controls when the rule fires. “On Create & Write” is the most common. Use “On State Change” when a rule should only apply when confirming an order or posting an invoice. Use “On Unlink” to prevent deletion of important records.

Scope – One2many Lines

Validates each row in a line table (e.g., each sales order line) instead of the header record. Useful for checking quantities, prices, or required fields on individual lines.

Apply When

An optional filter. The rule only runs when the record matches this condition. Example: require VAT only when the contact is a company, not an individual.

Severity – Block vs. Warning

Use Block for rules that must never be broken (missing tax ID, negative quantities). Use Warning for soft reminders (phone number recommended but not mandatory).

Error Message

Write this for the person who sees it — be specific and helpful. Instead of “Validation failed,” say “Please enter a phone number with at least 10 digits.”

Unique Value — Composite

Check uniqueness across multiple fields together. Example: the same VAT number can exist in different countries, but not twice in the same country.

Tips

Common Mistakes

Image

Creating Validation Rules