This question has been flagged
1 Reply
8988 Views

I have seen in some Odoo files:

from ..models import MAGIC_COLUMNS

What are these columns?  Why are they considered magical?

Avatar
Discard
Author Best Answer

Magic Columns are fields that Odoo manages exclusively - like magic - without any user intervention required.


They are defined at https://github.com/odoo/odoo/blob/11.0/odoo/models.py#L187

LOG_ACCESS_COLUMNS = ['create_uid', 'create_date', 'write_uid', 'write_date']

MAGIC_COLUMNS = ['id'] + LOG_ACCESS_COLUMNS

In some cases, other field names are added to this list:

parent_left
parent_right
__last_update

You don't have to worry about them - they are created and populated automatically when needed.

When you make your own fields for models, you just can't use any Magic Field names, or any of the following Reserved field names:

name
active
sequence
state
parent_id
Avatar
Discard