Xavier ALT (OpenERP) has proposed merging
lp:~openerp-dev/openobject-server/6.0-opw-383628-xal into
lp:openobject-server/6.0.
Requested reviews:
Naresh(OpenERP) (nch-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/6.0-opw-383628-xal/+merge/100559
Hi,
This force copy of "float" fields upon module loading, so that the "digits"
cache inside the fields is specific to the pool, not server-wide. This was
causing problem of decimal precision changing server-wide when connecter to a
new DB.
NOTE: This is a backport of v6.1, but the fix in v6.1 only work for inherited
object, base objects are still facing the problem - this MP will fix both.
Steps:
- Create a database "A" - with sale module
- Create a database "B" - with sale module
- Connect to database "A", change "Sale" precision to 4, check on sale order
line - precision is 4.
- Connect to database "B"
- Re-connect to database "A", check on sale order line - precision is now 2
(*wrong*)
Current: float field precision are overwritten uppon when a new database is
loaded
Expected: float field precision should be per-pool (per database)
--
https://code.launchpad.net/~openerp-dev/openobject-server/6.0-opw-383628-xal/+merge/100559
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-server/6.0-opw-383628-xal.
=== modified file 'bin/osv/osv.py'
--- bin/osv/osv.py 2011-05-25 13:26:12 +0000
+++ bin/osv/osv.py 2012-04-03 07:06:26 +0000
@@ -303,12 +303,23 @@
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-pool, 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, {}))
else:
new.extend(cls.__dict__.get(s, []))
nattr[s] = new
cls = type(name, (cls, parent_class), nattr)
+ else:
+ # Duplicate float fields because they have a .digits
+ # cache (which must be per-pool, not server-wide).
+ for field_name, field in cls._columns.items():
+ if field._type == 'float':
+ cls._columns[field_name] = copy.copy(field)
obj = object.__new__(cls)
obj.__init__(pool, cr)
@@ -342,6 +353,12 @@
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-pool, 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, {}))
else:
@@ -365,6 +382,12 @@
new.extend(cls.__dict__.get(s, []))
nattr[s] = new
cls = type(name, (cls, parent_class), nattr)
+ else:
+ # Duplicate float fields because they have a .digits
+ # cache (which must be per-pool, not server-wide).
+ for field_name, field in cls._columns.items():
+ if field._type == 'float':
+ cls._columns[field_name] = copy.copy(field)
obj = object.__new__(cls)
obj.__init__(pool, cr)
return obj
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp