From 79bd2f3062b039d39b6f0f0259a9e8efae08acc8 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 --- .../report/stock_history_views.xml | 6 +++++ .../wizard/wizard_valuation_history.py | 25 ++++++++++++------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/addons/stock_account/report/stock_history_views.xml b/addons/stock_account/report/stock_history_views.xml index 888ac577e26..085a73fe319 100644 --- a/addons/stock_account/report/stock_history_views.xml +++ b/addons/stock_account/report/stock_history_views.xml @@ -58,4 +58,10 @@ + + Stock History + stock.history + form + tree,graph,pivot + diff --git a/addons/stock_account/wizard/wizard_valuation_history.py b/addons/stock_account/wizard/wizard_valuation_history.py index 889db533a83..4da1ffe5d4d 100644 --- a/addons/stock_account/wizard/wizard_valuation_history.py +++ b/addons/stock_account/wizard/wizard_valuation_history.py @@ -19,12 +19,19 @@ class WizardValuationHistory(models.TransientModel): history_date=self.date, search_default_group_by_product=True, search_default_group_by_location=True) - return { - 'domain': "[('date', '<=', '" + self.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.env['ir.model.data'].xmlid_to_object('stock_account.action_stock_history') + 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', '<=', '" + self.date + "')]" + action['name'] = _('Stock Value At Date') + action['context'] = ctx + return action