[FIX] lunch: Cache lunch product images

Images of the lunch dashboard are not cached by the browser.

closes odoo/odoo#47427

X-original-commit: fec2e2a49faa69d2ce554e62a3de196573fa3656
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
Lucas Lefèvre
2020-03-11 16:05:07 +00:00
parent 8298712468
commit 35c144c28a
+12 -1
View File
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models, tools
from odoo import api, fields, models, tools
from odoo.osv import expression
@@ -41,6 +41,17 @@ class LunchProductReport(models.Model):
else:
product_r.image_128 = False
def compute_concurrency_field(self):
"""Image caching is based on the `__last_update` field (=self.CONCURRENCY_CHECK_FIELD)
But the image is never cached by the browser because the value fallbacks to
`now` when access logging is disabled. This override sets a "real" value based on the
product or category last update.
"""
for report in self:
product_last_update = report.product_id[self.CONCURRENCY_CHECK_FIELD]
category_last_update = report.category_id[self.CONCURRENCY_CHECK_FIELD]
report[self.CONCURRENCY_CHECK_FIELD] = max(product_last_update, category_last_update)
def _compute_is_available_at(self):
"""
Is available_at is always false when browsing it