How to Use Key Mixins and Classes in Odoo 18

Hello Odooers,

Today, I would like to share some important information with you about one of the most essential parts of Odoo development — the key mixins and classes in Odoo 18. If you're building custom modules, understanding these will make your code cleaner, more reusable, and aligned with Odoo best practices.

What are Mixins in Odoo?

In Odoo, Mixins are like helper models. You don't use them directly to create records.

Instead, they are designed to be inherited by other models.

Their purpose is to:

  • Provide common fields that can be reused
  • Share methods (functions) that many models need
  • Keep common logic in one place so you don't have to write the same code repeatedly.

This makes your code cleaner, shorter, and easier to maintain.

.py

from odoo import models

class MyCustomMixin(models.AbstractModel):

_name = 'my.custom.mixin'

_description = 'My Custom Mixin'

def common_logic(self):

# This method can be reused in any model that inherits this mixin pass

Base Classes in Odoo 18

1. models.Model

This is the main base class. Almost every Odoo model inherits from it. It provides ORM features such as create(), search(), write(), and unlink().

.py


class MyModel(models.Model):

_name = "my.model"

name = fields.Char("Name")

        fees = fields.Float(string='Total fees', compute='compute_total_fees')

2. models.TransientModel

Used for wizards. Records are temporary and auto-cleaned after use.

.py

class MyWizard(models.TransientModel):

_name = "my.wizard"

field_x = fields.Char("Temporary Field")

3. models.AbstractModel

Useful for shared logic across multiple models. Cannot be instantiated directly.

In Odoo,Commonly Used Mixins 

a) mail.thread & mail.activity.mixin

Enables chatter, messages, followers, and activities.

.py

class MyTask(models.Model):

_name = "my.task"

_inherit = ["mail.thread", "mail.activity.mixin"]

name = fields.Char("Task", tracking=True)

b) portal.mixin

Makes records accessible on the customer portal with features like access_url.

c) sequence.mixin

Automatically generates sequence numbers for records, e.g., Sales Orders or Invoices.

d) rating.mixin

Adds rating/feedback capability, often used in Helpdesk and Projects.

e) website.published.mixin

Controls publish/unpublish status on the website (common in eCommerce and Blogs).

Why Are They Important?

  • Save you from writing repetitive code.
  • Ensure consistency across apps.
  • Make your modules integrate smoothly with Odoo.

That’s a quick overview of the key mixins and classes in Odoo 18. Mastering them will help you become a more efficient Odoo developer.

Stay tuned for more technical blogs from Devintelle, where we share real Odoo development tips and best practices. 

Odoo DEV September 22, 2025
Archive
Sign in to leave a comment
Add Button Next to Create Button in Tree & Form Views in Odoo 18