Skip to content

Commit

Permalink
Do not force commit in computed fields
Browse files Browse the repository at this point in the history
The following commit leads to `CacheMissed` errors when retrieving an
album image for the first time:
odoo/odoo@0f6875a

It happens because a call to `commit` also clears the cache.

In order to fix the issue, we could assign the value to the computed
field after the `commit` call. However, the programmatic call to
`commit` is not necessary since it happens automatically at the end of
the transaction.
  • Loading branch information
DocMarty84 committed Jul 5, 2020
1 parent 2d46b0e commit 90cc245
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions models/oomusic_folder.py
Expand Up @@ -291,7 +291,6 @@ def _compute_image_big(self):
# Save in cache
try:
folder.sudo().write({"image_big_cache": resized_image})
self.env.cr.commit()
except OperationalError:
_logger.warning(
"Error when writing image cache for folder id: %s", folder.id, exc_info=True
Expand Down Expand Up @@ -324,7 +323,6 @@ def _compute_image_medium(self):
# Save in cache
try:
folder.sudo().write({"image_medium_cache": resized_image})
self.env.cr.commit()
except OperationalError:
_logger.warning(
"Error when writing image cache for folder id: %s", folder.id, exc_info=True
Expand Down Expand Up @@ -357,7 +355,6 @@ def _compute_image_small(self):
# Save in cache
try:
folder.sudo().write({"image_small_cache": resized_image})
self.env.cr.commit()
except OperationalError:
_logger.warning(
"Error when writing image cache for folder id: %s", folder.id, exc_info=True
Expand Down

0 comments on commit 90cc245

Please sign in to comment.