From 35c144c28ad9f3715b408b6d8aaec939972a5e8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Lef=C3=A8vre?= Date: Fri, 6 Mar 2020 15:48:16 +0000 Subject: [PATCH] [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) --- addons/lunch/report/lunch_product_report.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/addons/lunch/report/lunch_product_report.py b/addons/lunch/report/lunch_product_report.py index 8ff8858487f..44953be8930 100644 --- a/addons/lunch/report/lunch_product_report.py +++ b/addons/lunch/report/lunch_product_report.py @@ -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