summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorced <>2007-01-26 12:51:51 +0000
committerced <>2007-01-26 12:51:51 +0000
commit6b621cbb8d2bc84a046e8a63a8fa417e49f7a662 (patch)
tree5edcc52cb279758dfa99d416677fe1524bb7da70
parentf4e6eece8040f51788cc952107e593eb2e1469a0 (diff)
REPORT_STOCK: add report on stock by stock location and production lots
bzr revid: ced-ad9dae55bc0b2f4b08b6d28ec89be438b90f320b
-rw-r--r--addons/report_stock/__init__.py29
-rw-r--r--addons/report_stock/__terp__.py14
-rw-r--r--addons/report_stock/report_stock.py77
-rw-r--r--addons/report_stock/report_stock_view.xml20
4 files changed, 140 insertions, 0 deletions
diff --git a/addons/report_stock/__init__.py b/addons/report_stock/__init__.py
new file mode 100644
index 00000000000..db3f7beca43
--- /dev/null
+++ b/addons/report_stock/__init__.py
@@ -0,0 +1,29 @@
+##############################################################################
+#
+# Copyright (c) 2007 TINY SPRL. (http://tiny.be) All Rights Reserved.
+# Fabien Pinckaers <fp@tiny.Be>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
+
+import report_stock
diff --git a/addons/report_stock/__terp__.py b/addons/report_stock/__terp__.py
new file mode 100644
index 00000000000..464a36bb00d
--- /dev/null
+++ b/addons/report_stock/__terp__.py
@@ -0,0 +1,14 @@
+{
+ "name" : "Stock report",
+ "version" : "1.0",
+ "author" : "Tiny",
+ "website" : "http://tinyerp.com/",
+ "depends" : ["stock", "product",],
+ "category" : "Generic Modules/Inventory Control",
+ "description" : "A module that adds new reports based on the stock module.",
+ "init_xml" : [],
+ "demo_xml" : [],
+ "update_xml" : ["report_stock_view.xml",],
+ "active": False,
+ "installable": True
+}
diff --git a/addons/report_stock/report_stock.py b/addons/report_stock/report_stock.py
new file mode 100644
index 00000000000..d3062548344
--- /dev/null
+++ b/addons/report_stock/report_stock.py
@@ -0,0 +1,77 @@
+##############################################################################
+#
+# Copyright (c) 2004-2007 TINY SPRL. (http://tiny.be) All Rights Reserved.
+#
+# $Id: stock.py 1005 2005-07-25 08:41:42Z nicoe $
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
+
+from osv import osv, fields
+
+class report_stock_prodlots(osv.osv):
+ _name = "report.stock.prodlots"
+ _description = "Report stock by production lots"
+ _auto = False
+ _columns = {
+ 'name': fields.float('Quantity', readonly=True),
+ 'location_id': fields.many2one('stock.location', 'Location', readonly=True, relate=True, select=True),
+ 'product_id': fields.many2one('product.product', 'Product', readonly=True, relate=True, select=True),
+ 'prodlot_id': fields.many2one('stock.production.lot', 'Production lot', readonly=True, relate=True, select=True),
+ }
+ def init(self, cr):
+ cr.execute("""
+ create or replace view report_stock_prodlots as (
+ select max(id) as id,
+ location_id,
+ product_id,
+ prodlot_id,
+ sum(qty) as name
+ from (
+ select -max(sm.id) as id,
+ sm.location_id,
+ sm.product_id,
+ sm.prodlot_id,
+ -sum(sm.product_qty) as qty
+ from stock_move as sm
+ left join stock_location sl
+ on (sl.id = sm.location_id)
+ where state = 'done'
+ and sl.usage = 'internal'
+ group by sm.location_id, sm.product_id, sm.product_uom, sm.prodlot_id
+ union all
+ select max(sm.id) as id,
+ sm.location_dest_id as location_id,
+ sm.product_id,
+ sm.prodlot_id,
+ sum(sm.product_qty) as qty
+ from stock_move as sm
+ left join stock_location sl
+ on (sl.id = sm.location_dest_id)
+ where sm.state = 'done'
+ and sl.usage = 'internal'
+ group by sm.location_dest_id, sm.product_id, sm.product_uom, sm.prodlot_id
+ ) as report
+ group by location_id, product_id, prodlot_id
+ )""")
+report_stock_prodlots()
diff --git a/addons/report_stock/report_stock_view.xml b/addons/report_stock/report_stock_view.xml
new file mode 100644
index 00000000000..2089b72ab62
--- /dev/null
+++ b/addons/report_stock/report_stock_view.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<terp>
+ <data>
+
+ <record model="ir.ui.view" id="report_stock_prodlots_tree">
+ <field name="name">report.stock.prodlots.view</field>
+ <field name="model">report.stock.prodlots</field>
+ <field name="type">tree</field>
+ <field name="arch" type="xml">
+ <tree string="Stock by production lots">
+ <field name="location_id" select="1"/>
+ <field name="product_id" select="1"/>
+ <field name="prodlot_id" select="1"/>
+ <field name="name"/>
+ </tree>
+ </field>
+ </record>
+
+ </data>
+</terp>