From 81acd4dee2975142b685f3f28da85e908ea067f8 Mon Sep 17 00:00:00 2001 From: Mitali Patel Date: Thu, 27 Oct 2016 16:29:45 +0530 Subject: [PATCH] [IMP] stock_account: merge inventory reports menus Previously we had 'Inventory at Date' (debug mode) and 'Inventory Valuation' Both have been merged into 'Inventory Valuation' that pops up a wizard asking whether you want the current one or the one from a specific date. Depending on which one you choose you will get either report from the previous menus. (stock.quant or stock.history model) --- .../wizard/wizard_valuation_history.py | 39 +++++++++++-------- .../wizard/wizard_valuation_history_views.xml | 18 ++++----- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/addons/stock_account/wizard/wizard_valuation_history.py b/addons/stock_account/wizard/wizard_valuation_history.py index 889db533a83..cda89d0a243 100644 --- a/addons/stock_account/wizard/wizard_valuation_history.py +++ b/addons/stock_account/wizard/wizard_valuation_history.py @@ -8,23 +8,30 @@ class WizardValuationHistory(models.TransientModel): _name = 'wizard.valuation.history' _description = 'Wizard that opens the stock valuation history table' - choose_date = fields.Boolean('Inventory at Date') - date = fields.Datetime('Date', default=fields.Datetime.now, required=True) + compute_at_date = fields.Selection([ + (0, 'Current Inventory'), + (1, 'At a Specific Date') + ], string="Compute", help="Choose to analyze the current inventory or from a specific date in the past.") + date = fields.Datetime('Inventory at Date', help="Choose a date to get the inventory at that date", default=fields.Datetime.now()) @api.multi def open_table(self): self.ensure_one() - ctx = dict( - self._context, - 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, - } + if self.compute_at_date and self.date: + ctx = dict( + self._context, + 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, + } + else: + action = self.env.ref('stock.quantsact').read()[0] + return action diff --git a/addons/stock_account/wizard/wizard_valuation_history_views.xml b/addons/stock_account/wizard/wizard_valuation_history_views.xml index bf65b78f0f6..48e8162e793 100644 --- a/addons/stock_account/wizard/wizard_valuation_history_views.xml +++ b/addons/stock_account/wizard/wizard_valuation_history_views.xml @@ -1,19 +1,15 @@ - Inventory at Date + Inventory Valuation Report wizard.valuation.history
-

- Choose a date in the past to get the inventory at that date. -

-

- Retrieve the curent stock valuation. -

- - + + + +