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 6313300ed1
commit 1d6fbfc797
1 file changed
+12 -10
+12 -10
View File
@@ -356,16 +356,18 @@ class Product(ModelSQL, ModelView):
context['stock_date_start'], today,
])
else:
period_ids = period_obj.search([
('date', '<', context['stock_date_end']),
], order=[('date', 'DESC')], limit=1)
if period_ids:
period_id, = period_ids
period = period_obj.browse(period_id)
state_date_clause += (' AND '
'(COALESCE(effective_date, planned_date) > %s)')
state_date_vals.append(period.date)
period_vals[0] = period.id
with Transaction().set_user(0, set_context=True):
period_ids = period_obj.search([
('date', '<', context['stock_date_end']),
('state', '=', 'closed'),
], order=[('date', 'DESC')], limit=1)
if period_ids:
period_id, = period_ids
period = period_obj.browse(period_id)
state_date_clause += (' AND '
'(COALESCE(effective_date, planned_date) > %s)')
state_date_vals.append(period.date)
period_vals[0] = period.id
if with_childs:
query, args = location_obj.search([