From 49f5aef548e0db3344f9bd2d980fd788046293af Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 20 Jan 2017 16:28:20 +0100 Subject: [PATCH] [FIX] stock_account: inventory at date The "Inventory at Date" has several issues: - graph and pivot views are not available despite their existence - the views are not linked to an action, thus it is impossible to save it on the dashboard. opw-703649 --- .../wizard/stock_valuation_history.py | 25 ++++++++++++------- .../wizard/stock_valuation_history_view.xml | 7 +++++- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/addons/stock_account/wizard/stock_valuation_history.py b/addons/stock_account/wizard/stock_valuation_history.py index 65169c6dc13..de07661f6cc 100644 --- a/addons/stock_account/wizard/stock_valuation_history.py +++ b/addons/stock_account/wizard/stock_valuation_history.py @@ -26,15 +26,22 @@ class wizard_valuation_history(osv.osv_memory): ctx['history_date'] = data['date'] ctx['search_default_group_by_product'] = True ctx['search_default_group_by_location'] = True - return { - 'domain': "[('date', '<=', '" + data['date'] + "')]", - 'name': _('Stock Value At Date'), - 'view_type': 'form', - 'view_mode': 'tree', - 'res_model': 'stock.history', - 'type': 'ir.actions.act_window', - 'context': ctx, - } + + action = self.pool.get('ir.model.data').xmlid_to_object(cr, uid, 'stock_account.action_stock_history', context=context) + if not action: + action = { + 'view_type': 'form', + 'view_mode': 'tree,graph,pivot', + 'res_model': 'stock.history', + 'type': 'ir.actions.act_window', + } + else: + action = action[0].read()[0] + + action['domain'] = "[('date', '<=', '" + data['date'] + "')]" + action['name'] = _('Stock Value At Date') + action['context'] = ctx + return action class stock_history(osv.osv): diff --git a/addons/stock_account/wizard/stock_valuation_history_view.xml b/addons/stock_account/wizard/stock_valuation_history_view.xml index 4955e193e9d..a67c0e37ef9 100644 --- a/addons/stock_account/wizard/stock_valuation_history_view.xml +++ b/addons/stock_account/wizard/stock_valuation_history_view.xml @@ -92,6 +92,11 @@ + + Stock History + stock.history + form + tree,graph,pivot + -