Manifest Academy

Home › Curriculum › Technical Foundations › Python essentials

Python for Odoo · 16 min · Python 3.12

Python essentials

Values, types, strings, lists, dicts, sets, control flow, functions and exceptions: the Python you'll read in every Odoo module.

In this lesson

Key points

Real-world example

A techno-functional consultant read a traceback ending in KeyError: 'discount' in a custom module. The code did vals['discount'] when the dict didn't always contain it. Changing it to vals.get('discount', 0.0) fixed a crash that had blocked a client's order imports for a day.

Questions and answers

What's the difference between a list and a tuple?

Lists are mutable; tuples are immutable.

How do you make a message translatable in Odoo?

Wrap it in _() imported from odoo (or self.env._ in recent versions).

Read the full lesson, worked example and quiz