Skip to content

Commit

Permalink
[IMP] fields: simplify definition of ID field
Browse files Browse the repository at this point in the history
  • Loading branch information
rco-odoo committed Mar 23, 2015
1 parent ffa7f28 commit 915af86
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions openerp/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -1784,15 +1784,15 @@ def convert_to_cache(self, value, record, validate=True):

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):
Expand Down

0 comments on commit 915af86

Please sign in to comment.