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. -

- - + + + +