From 2a9f1ae7e1322a8452cd6e1dbaa6d2b2829a0d1d Mon Sep 17 00:00:00 2001 From: "Vir (Open ERP)" Date: Tue, 2 Feb 2010 18:40:24 +0530 Subject: [PATCH] [MOD] Improvement in Sql view bzr revid: vir@tinyerp.com-20100202131024-ohz2u0s3hfxe2ko2 --- .../board_warehouse/board_warehouse_view.xml | 13 +++++- addons/stock/stock.py | 44 ++++++++++++++----- addons/stock/stock_view.xml | 2 +- 3 files changed, 44 insertions(+), 15 deletions(-) diff --git a/addons/board_warehouse/board_warehouse_view.xml b/addons/board_warehouse/board_warehouse_view.xml index 0ea7fb48297..cdc93d9a274 100644 --- a/addons/board_warehouse/board_warehouse_view.xml +++ b/addons/board_warehouse/board_warehouse_view.xml @@ -5,6 +5,15 @@ Warehouse + + Reception Picking Stock Move + stock.move + ir.actions.act_window + form + tree,form + [('picking_id','!=',False),('picking_id.type','=','in'),('date','<=',time.strftime('%Y-%m-%d 23:59:59'))] + + board.warehouse.form @@ -15,11 +24,11 @@ - + - + diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 1e91f182568..cc4da8bdbbd 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1656,12 +1656,21 @@ class report_products_to_received_planned(osv.osv): tools.drop_view_if_exists(cr, 'report_products_to_received_planned') cr.execute(""" create or replace view report_products_to_received_planned as ( - select - distinct current_date as date, - min(id) as id, - (select sum(product_qty) from stock_move where to_char(date,'YYYY-MM-DD')::date = current_date ) as qty, - (select sum(product_qty) from stock_move where to_char(date_planned,'YYYY-MM-DD')::date = current_date) as planned_qty - from stock_move + select stock.date, min(stock.id), sum(stock.product_qty) as qty, 0 as planned_qty + from stock_picking picking + inner join stock_move stock + on picking.id = stock.picking_id and picking.type = 'in' + where stock.date between (select cast(date_trunc('week', current_date) as date)) and (select cast(date_trunc('week', current_date) as date) + 7) + group by stock.date + + union + + select stock.date_planned, min(stock.id), 0 as actual_qty, sum(stock.product_qty) as planned_qty + from stock_picking picking + inner join stock_move stock + on picking.id = stock.picking_id and picking.type = 'in' + where stock.date_planned between (select cast(date_trunc('week', current_date) as date)) and (select cast(date_trunc('week', current_date) as date) + 7) + group by stock.date_planned ) """) report_products_to_received_planned() @@ -1681,12 +1690,23 @@ class report_delivery_products_planned(osv.osv): tools.drop_view_if_exists(cr, 'report_delivery_products_planned') cr.execute(""" create or replace view report_delivery_products_planned as ( - select - distinct current_date as date, - min(sm.id) as id, - (select sum(product_qty) from stock_move join stock_picking sp on (sm.picking_id = sp.id ) where to_char(sm.date,'YYYY-MM-DD')::date = current_date ) as qty, - (select sum(product_qty) from stock_move join stock_picking sp on (sm.picking_id = sp.id ) where to_char(sm.date_planned,'YYYY-MM-DD')::date = current_date) as planned_qty - from stock_move sm join stock_picking sp on (sm.picking_id = sp.id ) where sp.type = 'out' group by sm.picking_id, sm.date, sm.date_planned + select stock.date, min(stock.id), sum(stock.product_qty) as qty, 0 as planned_qty + from stock_picking picking + inner join stock_move stock + on picking.id = stock.picking_id and picking.type = 'out' + where stock.date between (select cast(date_trunc('week', current_date) as date)) and (select cast(date_trunc('week', current_date) as date) + 7) + group by stock.date + + union + + select stock.date_planned, min(stock.id), 0 as actual_qty, sum(stock.product_qty) as planned_qty + from stock_picking picking + inner join stock_move stock + on picking.id = stock.picking_id and picking.type = 'out' + where stock.date_planned between (select cast(date_trunc('week', current_date) as date)) and (select cast(date_trunc('week', current_date) as date) + 7) + group by stock.date_planned + + ) """) report_delivery_products_planned() diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 9adf0bbecba..42bef7b13d7 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -1515,7 +1515,7 @@ - Reception Picking Stock Move + Number of Products to receive Vs planned report.products.to.received.planned ir.actions.act_window form