Skip to content

Commit

Permalink
[FIX] decimal_precision: avoid refreshing float precisions at each ca…
Browse files Browse the repository at this point in the history
…che invalidation

Changing the decimal precision of float fields is a rare
operation, while cache clearing occurs fairly frequently.
Signaling a full registry change when the decimal precision
is changed (instead of a mere cache change) is therefore
a better trade-off, and more semantically correct as well.
This way we avoid the decimal precision refresh for each
invalidation.

Registry invalidation implies cache invalidation.
  • Loading branch information
odony committed Nov 19, 2014
1 parent 8ce8973 commit c87b9c6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
2 changes: 1 addition & 1 deletion addons/decimal_precision/decimal_precision.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def clear_cache(self, cr):
for field in model._fields.values():
if field.type == 'float':
field._setup_digits(env)
RegistryManager.signal_caches_change(cr.dbname)
RegistryManager.signal_registry_change(cr.dbname)

def create(self, cr, uid, data, context=None):
res = super(decimal_precision, self).create(cr, uid, data, context=context)
Expand Down
8 changes: 0 additions & 8 deletions openerp/modules/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,14 +429,6 @@ def check_registry_signaling(cls, db_name):
_logger.info("Invalidating all model caches after database signaling.")
registry.clear_caches()
registry.reset_any_cache_cleared()
# One possible reason caches have been invalidated is the
# use of decimal_precision.write(), in which case we need
# to refresh fields.float columns.
env = openerp.api.Environment(cr, SUPERUSER_ID, {})
for model in registry.values():
for field in model._fields.values():
if field.type == 'float':
field._setup_digits(env)
registry.base_registry_signaling_sequence = r
registry.base_cache_signaling_sequence = c
finally:
Expand Down

0 comments on commit c87b9c6

Please sign in to comment.