odoo-automated-tests
Helps your agent write and run automated tests for Odoo, ensuring software quality.
What it does
Helps write and run automated tests for the Odoo system. This ensures new features don't break existing ones.
When to use it
- ✓When you create a new feature and want to make sure everything still works.
- ✓To check if a specific part of the system responds correctly.
- ✓When automated tests fail and you need to understand why.
Example of what to ask your AI
“Create a test for the functionality of creating a new patient in the hospital module, ensuring the name cannot be empty.”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
You describe what you want to test, and the tool generates the test code for you. Then, it tells you how to run that test in the system.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add sickn33/agentic-awesome-skills --skill odoo-automated-testsOr download just the file:
curl -L https://raw.githubusercontent.com/sickn33/agentic-awesome-skills/main/plugins/agentic-awesome-skills-claude/skills/odoo-automated-tests/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
Odoo Automated Tests
Overview
Odoo has a built-in testing framework based on Python's unittest. This skill helps you write TransactionCase unit tests, HttpCase integration tests, and JavaScript tour tests. It also covers running tests in CI pipelines.
When to Use This Skill
- Writing unit tests for a custom model's business logic.
- Creating an HTTP test to verify a controller endpoint.
- Debugging test failures in a CI pipeline.
- Setting up automated test execution with
--test-enable.
How It Works
- Activate: Mention
@odoo-automated-testsand describe the feature to test. - Generate: Get complete test class code with setup, teardown, and assertions.
- Run: Get the exact
odooCLI command to execute your tests.
Examples
Example 1: TransactionCase Unit Test (Odoo 15+ pattern)
# tests/test_hospital_patient.py
from odoo.tests.common import TransactionCase
from odoo.tests import tagged
from odoo.exceptions import ValidationError
@tagged('post_install', '-at_install')
class TestHospitalPatient(TransactionCase):
@classmethod
def setUpClass(cls):
# Use setUpClass for performance — runs once per class, not per test
super().setUpClass()
cls.Patient = cls.env['hospital.patient']
cls.doctor = cls.env['res.users'].browse(cls.env.uid)
def test_create_patient(self):
patient = self.Patient.create({
'name': 'John Doe',
'doctor_id': self.doctor.id,
})
self.assertEqual(patient.state, 'draft')
self.assertEqual(patient.name, 'John Doe')
def test_confirm_patient(self):
patient = self.Patient.create({'name': 'Jane Smith'})
patient.action_confirm()
self.assertEqual(patient.state, 'confirmed')
def test_empty_name_raises_error(self):
with self.assertRaises(ValidationError):
self.Patient.create({'name': ''})
def test_access_denied_for_other_user(self):
# Test security rules by running as a different user
other_user = self.env.ref('base.user_demo')
with self.assertRaises(Exception):
self.Patient.with_user(other_user).create({'name': 'Test'})
setUpClassvssetUp: UsesetUpClass(Odoo 15+) for shared test data. It runs once per class and is significantly faster thansetUpwhich re-initializes for every single test method.
Example 2: Run Tests via CLI
# Run all tests for a specific module
./odoo-bin --test-enable --stop-after-init -d my_database -u hospital_management
# Run only tests tagged with a specific tag
./odoo-bin --test-enable --stop-after-init -d my_database \
--test-tags hospital_management
# Run a specific test class
./odoo-bin --test-enable --stop-after-init -d my_database \
--test-tags /hospital_management:TestHospitalPatient
Example 3: HttpCase for Controller Testing
from odoo.tests.common import HttpCase
from odoo.tests import tagged
@tagged('post_install', '-at_install')
class TestPatientController(HttpCase):
def test_patient_page_authenticated(self):
# Authenticate as a user, not with hardcoded password
self.authenticate(self.env.user.login, self.env.user.login)
resp = self.url_open('/hospital/patients')
self.assertEqual(resp.status_code, 200)
def test_patient_page_redirects_unauthenticated(self):
# No authenticate() call = public/anonymous user
resp = self.url_open('/hospital/patients', allow_redirects=False)
self.assertIn(resp.status_code, [301, 302, 403])
Best Practices
- ✅ Do: Use
setUpClass()withcls.envinstead ofsetUp()— it is dramatically faster for large test suites. - ✅ Do: Use
@tagged('post_install', '-at_install')to run tests after all modules are installed. - ✅ Do: Test both the happy path and error conditions (
ValidationError,AccessError,UserError). - ✅ Do: Use
self.with_user(user)to test access control without callingsudo(). - ❌ Don't: Use a production database for tests — always use a dedicated test database.
- ❌ Don't: Rely on test execution order — each
TransactionCasetest is rolled back in isolation. - ❌ Don't: Hardcode passwords in
HttpCase.authenticate()— useself.env.user.loginor a fixture user.
Limitations
- JavaScript tour tests require a running browser (via
phantomjsorChrome headless) and a live Odoo server — not covered in depth here.
…
FAQ
What's the difference between TransactionCase and HttpCase?
TransactionCase tests the internal logic of the system (like calculations or business rules), while HttpCase tests how the system responds to internet requests (like accessing a page).
Can I use this in any Odoo version?
The tool is based on Odoo's testing framework, which exists in various versions. The examples show newer patterns, but the concept is applicable.
What are 'CI tests'?
CI stands for Continuous Integration. These are tests that run automatically whenever code is updated, to catch errors quickly.
Details
Original description by the author
Write and run Odoo automated tests using TransactionCase, HttpCase, and browser tour tests. Covers test data setup, mocking, and CI integration.
Popularity
- GitHub stars
- 48k
- Ranking position
- #3720
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
00-andruia-consultant
Helps your agent start or improve AI projects. It analyzes code, suggests tools, and creates action plans in Spanish.
sickn33/agentic-awesome-skills
007
Lets your agent perform security audits and threat modeling. It's useful for protecting projects against attacks and vulnerabilities.
sickn33/agentic-awesome-skills
10-andruia-skill-smith
Helps your agent create or improve AI tools. It defines how tools work, writes documentation, and validates the structure.
sickn33/agentic-awesome-skills
20-andruia-niche-intelligence
Lets your agent create a summary about a specific industry. It's useful for understanding the context, rules, usage patterns, and risks of a project, using reliable sources.
sickn33/agentic-awesome-skills
Similar skills
cpp-testing
Makes your agent write and improve tests for C++ code. It helps set up testing tools and fix errors.
affaan-m/ECC
csharp-testing
Helps your agent create tests for C# and .NET code. It uses best practices to ensure tests are efficient and reliable.
affaan-m/ECC
django-tdd
Enables your agent to apply testing strategies for Django with pytest-django and TDD. It's useful for writing robust tests and ensuring code quality, especially for DRF APIs.
affaan-m/ECC