From 267c1d0649783f8e23fcb06b704d0743f9934df4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 22 May 2013 19:18:43 +0200 Subject: [PATCH] Use root to search on period and search on closed periods products_by_location can be called by users without read access to period. And only closed period has cache. review875002 (transplanted from 09d5333339c1d345dae85e5f3180d8a240bf5848) --- product.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/product.py b/product.py index 0344367c49..be694ff1f5 100644 --- a/product.py +++ b/product.py @@ -385,9 +385,11 @@ class Product: context['stock_date_start'], today, ]) else: - periods = Period.search([ - ('date', '<', context['stock_date_end']), - ], order=[('date', 'DESC')], limit=1) + with Transaction().set_user(0, set_context=True): + periods = Period.search([ + ('date', '<', context['stock_date_end']), + ('state', '=', 'closed'), + ], order=[('date', 'DESC')], limit=1) if periods: period, = periods state_date_clause += (' AND '