[FIX] fields: copy origin to avoid sharing field objects between registries

Fix a bug introduced in revision f229974, where shared columns objects are
systematically reintroduced in registries.
This commit is contained in:
Denis Ledoux 2014-09-30 13:29:54 +02:00 committed by Raphael Collet
parent 2796604b49
commit 30a0814159
2 changed files with 3 additions and 8 deletions

View File

@ -598,7 +598,9 @@ class Field(object):
assert self.store
if self._origin:
assert isinstance(self._origin, fields._column)
return self._origin
# some columns are registry-dependent, like float fields (digits);
# duplicate them to avoid sharing between registries
return copy(self._origin)
_logger.debug("Create fields._column for Field %s", self)
args = {}

View File

@ -39,7 +39,6 @@
"""
import copy
import datetime
import functools
import itertools
@ -653,12 +652,6 @@ class BaseModel(object):
}
cls = type(cls._name, (cls,), attrs)
# float fields are registry-dependent (digit attribute); duplicate them
# to avoid issues
for key, col in cls._columns.items():
if col._type == 'float':
cls._columns[key] = copy.copy(col)
# instantiate the model, and initialize it
model = object.__new__(cls)
model.__init__(pool, cr)