コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
11196 ビュー

I have seen in some Odoo files:

from ..models import MAGIC_COLUMNS

What are these columns?  Why are they considered magical?

アバター
破棄
著作者 最善の回答

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
アバター
破棄