diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index 86d743c5a6d..b9856de1224 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -65,6 +65,7 @@ Thanks to the double entry management, the inventory controlling is powerful and "product_data.xml", "product_view.xml", "partner_view.xml", + "report/report_stock_move_view.xml", "report/report_stock_view.xml", "report/report_stock_picking_view.xml", "security/stock_security.xml", diff --git a/addons/stock/report/__init__.py b/addons/stock/report/__init__.py index 6e0bc044d3e..a0a4bcb8ea5 100644 --- a/addons/stock/report/__init__.py +++ b/addons/stock/report/__init__.py @@ -27,6 +27,7 @@ import picking import lot_overview import lot_overview_all import report_stock +import report_stock_move import report_stock_picking # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/stock/report/report_stock_move.py b/addons/stock/report/report_stock_move.py new file mode 100755 index 00000000000..b5388b336e6 --- /dev/null +++ b/addons/stock/report/report_stock_move.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import tools +from osv import fields,osv + + +class report_stock_move(osv.osv): + _name = "report.stock.move" + _description = "Stock Statistics" + _auto = False + _columns = { + 'date': fields.date('Date', readonly=True), + 'year': fields.char('Year', size=4, readonly=True), + 'day': fields.char('Day', size=128, readonly=True), + 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), + ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'), + ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True), + 'product_id':fields.many2one('product.product', 'Product', readonly=True), + 'location_id':fields.many2one('stock.location', 'Location', readonly=True), + 'product_qty':fields.integer('Qty',readonly=True), + 'state': fields.selection([('draft', 'Draft'), ('waiting', 'Waiting'), ('confirmed', 'Confirmed'), ('assigned', 'Available'), ('done', 'Done'), ('cancel', 'Cancelled')], 'State', readonly=True, select=True, + help='When the stock move is created it is in the \'Draft\' state.\n After that it is set to \'Confirmed\' state.\n If stock is available state is set to \'Avaiable\'.\n When the picking it done the state is \'Done\'.\ + \nThe state is \'Waiting\' if the move is waiting for another one.'), + + } + + def init(self, cr): + tools.drop_view_if_exists(cr, 'report_stock_move') + cr.execute(""" + create or replace view report_stock_move as ( + select min(m.id) as id, + m.date as date, + to_char(date_trunc('day',m.date), 'YYYY') as year, + to_char(date_trunc('day',m.date), 'MM') as month, + to_char(date_trunc('day',m.date), 'YYYY-MM-DD') as day, + m.location_id as location_id, + m.product_id as product_id, + m.state as state, + sum(m.product_qty) as product_qty + from stock_move as m group by m.product_id, m.location_id, m.id, m.date, m.state + ) + """) +report_stock_move() diff --git a/addons/stock/report/report_stock_move_view.xml b/addons/stock/report/report_stock_move_view.xml new file mode 100755 index 00000000000..c44ce4773ef --- /dev/null +++ b/addons/stock/report/report_stock_move_view.xml @@ -0,0 +1,99 @@ + + + + + report.stock.move.tree + report.stock.move + tree + + + + + + + + + + + + + + + + report.stock.move.graph + report.stock.move + graph + + + + + + + + + + report.stock.move.search + report.stock.move + search + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Stock Moves + report.stock.move + form + tree,graph + + + + + + \ No newline at end of file