Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
11112 Widoki

I have seen in some Odoo files:

from ..models import MAGIC_COLUMNS

What are these columns?  Why are they considered magical?

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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
Awatar
Odrzuć