From 2f90f80ba083f29e2697c330664ea42c42e45555 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 16 Jan 2014 16:37:08 +0100 Subject: [PATCH] [FIX] orm: As float fields are stateful (the .digit attribute depend of the database (decimal_precision)), registry model instances need their owm copy. lp bug: https://launchpad.net/bugs/929483 fixed bzr revid: chs@openerp.com-20140116153708-061aq2k0n1qsb2n3 --- openerp/osv/orm.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 90428dfa21d..e7121bb4635 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -896,11 +896,6 @@ class BaseModel(object): for c in new.keys(): if new[c].manual: del new[c] - # Duplicate float fields because they have a .digits - # cache (which must be per-registry, not server-wide). - for c in new.keys(): - if new[c]._type == 'float': - new[c] = copy.copy(new[c]) if hasattr(new, 'update'): new.update(cls.__dict__.get(s, {})) elif s=='_constraints': @@ -936,6 +931,13 @@ class BaseModel(object): if not getattr(cls, '_original_module', None): cls._original_module = cls._module obj = object.__new__(cls) + + if hasattr(obj, '_columns'): + # float fields are registry-dependent (digit attribute). Duplicate them to avoid issues. + for c, f in obj._columns.items(): + if f._type == 'float': + obj._columns[c] = copy.copy(f) + obj.__init__(pool, cr) return obj