~acsone-openerp/openobject-server/7.0-bug-1076541

« back to all changes in this revision

Viewing changes to openerp/osv/orm.py

  • Committer: Christophe Simonis
  • Date: 2014-01-16 15:37:08 UTC
  • Revision ID: chs@openerp.com-20140116153708-061aq2k0n1qsb2n3
[FIX] orm: As float fields are stateful (the .digit attribute depend of the database (decimal_precision)), registry model instances need their owm copy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
896
896
                        for c in new.keys():
897
897
                            if new[c].manual:
898
898
                                del new[c]
899
 
                        # Duplicate float fields because they have a .digits
900
 
                        # cache (which must be per-registry, not server-wide).
901
 
                        for c in new.keys():
902
 
                            if new[c]._type == 'float':
903
 
                                new[c] = copy.copy(new[c])
904
899
                    if hasattr(new, 'update'):
905
900
                        new.update(cls.__dict__.get(s, {}))
906
901
                    elif s=='_constraints':
936
931
        if not getattr(cls, '_original_module', None):
937
932
            cls._original_module = cls._module
938
933
        obj = object.__new__(cls)
 
934
 
 
935
        if hasattr(obj, '_columns'):
 
936
            # float fields are registry-dependent (digit attribute). Duplicate them to avoid issues.
 
937
            for c, f in obj._columns.items():
 
938
                if f._type == 'float':
 
939
                    obj._columns[c] = copy.copy(f)
 
940
 
939
941
        obj.__init__(pool, cr)
940
942
        return obj
941
943