[IMP] fields: reset decimal precision on new-style fields
When a decimal_precision record is created/modified, the float fields of the models in the registry must be reset. This was done on old-API columns only. It is now handled by the new-API fields.
This commit is contained in:
parent
e31d25c867
commit
764c5acd81
|
@ -48,10 +48,11 @@ class decimal_precision(orm.Model):
|
||||||
def clear_cache(self, cr):
|
def clear_cache(self, cr):
|
||||||
"""clear cache and update models. Notify other workers to restart their registry."""
|
"""clear cache and update models. Notify other workers to restart their registry."""
|
||||||
self.precision_get.clear_cache(self)
|
self.precision_get.clear_cache(self)
|
||||||
for obj in self.pool.obj_list():
|
env = openerp.api.Environment(cr, SUPERUSER_ID, {})
|
||||||
for colname, col in self.pool.get(obj)._columns.items():
|
for model in self.pool.values():
|
||||||
if hasattr(col, 'digits_change'):
|
for field in model._fields.values():
|
||||||
col.digits_change(cr)
|
if field.type == 'float':
|
||||||
|
field._setup_digits(env)
|
||||||
RegistryManager.signal_caches_change(cr.dbname)
|
RegistryManager.signal_caches_change(cr.dbname)
|
||||||
|
|
||||||
def create(self, cr, uid, data, context=None):
|
def create(self, cr, uid, data, context=None):
|
||||||
|
|
|
@ -933,9 +933,16 @@ class Float(Field):
|
||||||
def __init__(self, string=None, digits=None, **kwargs):
|
def __init__(self, string=None, digits=None, **kwargs):
|
||||||
super(Float, self).__init__(string=string, _digits=digits, **kwargs)
|
super(Float, self).__init__(string=string, _digits=digits, **kwargs)
|
||||||
|
|
||||||
|
def _setup_digits(self, env):
|
||||||
|
""" Setup the digits for `self` and its corresponding column """
|
||||||
|
self.digits = self._digits(env.cr) if callable(self._digits) else self._digits
|
||||||
|
if self.store:
|
||||||
|
column = env[self.model_name]._columns[self.name]
|
||||||
|
column.digits_change(env.cr)
|
||||||
|
|
||||||
def _setup_regular(self, env):
|
def _setup_regular(self, env):
|
||||||
super(Float, self)._setup_regular(env)
|
super(Float, self)._setup_regular(env)
|
||||||
self.digits = self._digits(env.cr) if callable(self._digits) else self._digits
|
self._setup_digits(env)
|
||||||
|
|
||||||
_related_digits = property(attrgetter('digits'))
|
_related_digits = property(attrgetter('digits'))
|
||||||
|
|
||||||
|
|
|
@ -415,10 +415,11 @@ class RegistryManager(object):
|
||||||
# One possible reason caches have been invalidated is the
|
# One possible reason caches have been invalidated is the
|
||||||
# use of decimal_precision.write(), in which case we need
|
# use of decimal_precision.write(), in which case we need
|
||||||
# to refresh fields.float columns.
|
# to refresh fields.float columns.
|
||||||
for model in registry.models.values():
|
env = openerp.api.Environment(cr, SUPERUSER_ID, {})
|
||||||
for column in model._columns.values():
|
for model in registry.values():
|
||||||
if hasattr(column, 'digits_change'):
|
for field in model._fields.values():
|
||||||
column.digits_change(cr)
|
if field.type == 'float':
|
||||||
|
field._setup_digits(env)
|
||||||
registry.base_registry_signaling_sequence = r
|
registry.base_registry_signaling_sequence = r
|
||||||
registry.base_cache_signaling_sequence = c
|
registry.base_cache_signaling_sequence = c
|
||||||
finally:
|
finally:
|
||||||
|
|
Loading…
Reference in New Issue