Skip to Content
Course content

OOP Basics: classes, objects, inheritance

Odoo models are Python classes — this lesson is the direct on-ramp to the framework.

Key topics

  • Class vs instance; __init__ and instance attributes; class attributes and shared state.
  • Instance methods, @classmethod, @staticmethod; self explained.
  • Inheritance: extending and overriding methods, super(), multiple inheritance basics.
  • Encapsulation conventions (public, _protected, __private); @property.
  • Dunder methods: __str__, __repr__, __eq__, __len__, __getitem__ — how objects plug into Python syntax.

Exercise / deliverable

Model a mini LMS: a Course class (title, lessons list, add/remove lesson, duration_hours property) and an inherited PublishedCourse that adds publish state and overrides __str__.

Level: Beginner | Duration: ~0.5h. Classes, instances, methods, inheritance and dunder methods — the exact concepts the Odoo ORM is built on.
Rating
0 0

There are no comments for now.