From ba435bc3a98ac2b1b1a0effad1e2d97ecb63324a Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Thu, 19 Mar 2015 12:11:44 +0100 Subject: [PATCH] [IMP] stock: adapt views of current inventory valuation and stock level forecast The stock level forecast view should have inverse columns and rows. The line graph is also better by default. The stock valuation view should only be in reporting (removed the graph part) and is replaced by a pivot and graph view of the quants in the warehouse menu. We only group by location by default. Use date_expected instead of date in stock level forecast and group dates by week by default. --- addons/stock/report/report_stock_forecast.py | 12 +++--- addons/stock/report/report_stock_forecast.xml | 9 ++-- addons/stock/stock_view.xml | 42 +++++++++++++++---- .../wizard/stock_valuation_history.py | 2 +- .../wizard/stock_valuation_history_view.xml | 16 +------ 5 files changed, 46 insertions(+), 35 deletions(-) diff --git a/addons/stock/report/report_stock_forecast.py b/addons/stock/report/report_stock_forecast.py index e89efad5b31..61397d5a25c 100644 --- a/addons/stock/report/report_stock_forecast.py +++ b/addons/stock/report/report_stock_forecast.py @@ -38,7 +38,7 @@ class report_stock_forecast(models.Model): END AS date, SUM(sq.qty) AS product_qty FROM - (SELECT min(date) AS date FROM stock_move AS sm + (SELECT min(date_expected) AS date FROM stock_move AS sm LEFT JOIN stock_location source_location ON sm.location_id = source_location.id LEFT JOIN @@ -59,7 +59,7 @@ class report_stock_forecast(models.Model): SELECT max(sm.id) as id, sm.product_id, - to_date(to_char(sm.date, 'YYYY/MM/DD'), 'YYYY/MM/DD') AS date, + to_date(to_char(sm.date_expected, 'YYYY/MM/DD'), 'YYYY/MM/DD') AS date, SUM(sm.product_qty) AS product_qty FROM stock_move as sm @@ -72,12 +72,12 @@ class report_stock_forecast(models.Model): WHERE sm.state IN ('confirmed','assigned','waiting') and source_location.usage != 'internal' and dest_location.usage = 'internal' - GROUP BY sm.date,sm.product_id + GROUP BY sm.date_expected,sm.product_id UNION ALL SELECT max(sm.id) as id, sm.product_id, - to_date(to_char(sm.date, 'YYYY/MM/DD'), 'YYYY/MM/DD') AS date, + to_date(to_char(sm.date_expected, 'YYYY/MM/DD'), 'YYYY/MM/DD') AS date, SUM(-(sm.product_qty)) AS product_qty FROM stock_move as sm @@ -90,7 +90,7 @@ class report_stock_forecast(models.Model): WHERE sm.state IN ('confirmed','assigned','waiting') and source_location.usage = 'internal' and dest_location.usage != 'internal' - GROUP BY sm.date,sm.product_id) + GROUP BY sm.date_expected,sm.product_id) as MAIN LEFT JOIN (SELECT DISTINCT date @@ -98,7 +98,7 @@ class report_stock_forecast(models.Model): ( SELECT CURRENT_DATE AS DATE UNION ALL - SELECT to_date(to_char(sm.date, 'YYYY/MM/DD'), 'YYYY/MM/DD') AS date + SELECT to_date(to_char(sm.date_expected, 'YYYY/MM/DD'), 'YYYY/MM/DD') AS date FROM stock_move sm LEFT JOIN stock_location source_location ON sm.location_id = source_location.id diff --git a/addons/stock/report/report_stock_forecast.xml b/addons/stock/report/report_stock_forecast.xml index 5e40b79cc68..269611c8777 100644 --- a/addons/stock/report/report_stock_forecast.xml +++ b/addons/stock/report/report_stock_forecast.xml @@ -6,8 +6,7 @@ report.stock.forecast - - + @@ -17,7 +16,7 @@ Stock.forecast.graph report.stock.forecast - + @@ -32,8 +31,8 @@ - - + + diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 9f60e360c41..0ffe0dc8aaf 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -1687,6 +1687,10 @@ + + + + @@ -1705,8 +1709,18 @@ Quants stock.quant form - tree,form,graph - This analysis gives you a fast overview on the current stock level of your products and their today's inventory value. + tree,form + {'search_default_internal_loc': 1, 'group_by': ['product_id', 'location_id']} + This analysis gives you a fast overview on the current stock level of your products and their current inventory value. + + + + Current Inventory + stock.quant + form + pivot,graph + {'search_default_internal_loc': 1} + This analysis gives you a fast overview on the current stock level of your products and their current inventory value. @@ -1759,19 +1773,31 @@ - + stock.quant.graph stock.quant - - - - + + + + + + stock.quant.pivot + stock.quant + + + + + + + + + @@ -1784,7 +1810,7 @@ - + {'default_product_id': active_id, 'search_default_product_id': active_id} diff --git a/addons/stock_account/wizard/stock_valuation_history.py b/addons/stock_account/wizard/stock_valuation_history.py index 193b19cbc7b..9b5db80f7b2 100644 --- a/addons/stock_account/wizard/stock_valuation_history.py +++ b/addons/stock_account/wizard/stock_valuation_history.py @@ -29,7 +29,7 @@ class wizard_valuation_history(osv.osv_memory): 'domain': "[('date', '<=', '" + data['date'] + "')]", 'name': _('Stock Value At Date'), 'view_type': 'form', - 'view_mode': 'tree,graph', + 'view_mode': 'tree', 'res_model': 'stock.history', 'type': 'ir.actions.act_window', 'context': ctx, diff --git a/addons/stock_account/wizard/stock_valuation_history_view.xml b/addons/stock_account/wizard/stock_valuation_history_view.xml index d2026b5a5ab..3561fe3c7a9 100644 --- a/addons/stock_account/wizard/stock_valuation_history_view.xml +++ b/addons/stock_account/wizard/stock_valuation_history_view.xml @@ -51,7 +51,7 @@ - + @@ -94,20 +94,6 @@ - - - Current Inventory - stock.history - ir.actions.act_window - [('date','<=',time.strftime('%Y-%m-%d %H:%M:%S'))] - form - tree,pivot,graph - -