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)
This commit is contained in:
Cédric Krier committed 2013-05-22 19:18:43 +02:00
1 parent 1216a7fdff
commit 267c1d0649
1 file changed
+5 -3
+5 -3
View File
@@ -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 '