From 915af86a915f44c4405509c27a0526bed64fc943 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Wed, 11 Mar 2015 12:26:02 +0100 Subject: [PATCH] [IMP] fields: simplify definition of ID field --- openerp/fields.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/openerp/fields.py b/openerp/fields.py index 3167819534a..aaf6ba20f9c 100644 --- a/openerp/fields.py +++ b/openerp/fields.py @@ -75,8 +75,8 @@ class MetaField(type): def __init__(cls, name, bases, attrs): super(MetaField, cls).__init__(name, bases, attrs) - if cls.type: - cls.by_type[cls.type] = cls + if cls.type and cls.type not in MetaField.by_type: + MetaField.by_type[cls.type] = cls # compute class attributes to avoid calling dir() on fields cls.column_attrs = [] @@ -1784,15 +1784,15 @@ class Serialized(Field): class Id(Field): """ Special case for field 'id'. """ + type = 'integer' + + string = 'ID' store = True #: Can't write this! readonly = True - def __init__(self, string=None, **kwargs): - super(Id, self).__init__(type='integer', string=string, **kwargs) - def to_column(self): - self.column = fields.integer('ID') + self.column = fields.integer(self.string) return self.column def __get__(self, record, owner):