1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
23 from osv import osv, fields
24 from tools.translate import _
27 # Check if it works with UoM ???
29 class stock_report_prodlots(osv.osv):
30 _name = "stock.report.prodlots"
31 _description = "Stock report by production lots"
34 'name': fields.float('Quantity', readonly=True),
35 'location_id': fields.many2one('stock.location', 'Location', readonly=True, select=True),
36 'product_id': fields.many2one('product.product', 'Product', readonly=True, select=True),
37 'prodlot_id': fields.many2one('stock.production.lot', 'Production lot', readonly=True, select=True),
42 create or replace view stock_report_prodlots as (
49 select -max(sm.id) as id,
53 -sum(sm.product_qty /uo.factor) as qty
55 left join stock_location sl
56 on (sl.id = sm.location_id)
57 left join product_uom uo
58 on (uo.id=sm.product_uom)
60 group by sm.location_id, sm.product_id, sm.product_uom, sm.prodlot_id
62 select max(sm.id) as id,
63 sm.location_dest_id as location_id,
66 sum(sm.product_qty /uo.factor) as qty
68 left join stock_location sl
69 on (sl.id = sm.location_dest_id)
70 left join product_uom uo
71 on (uo.id=sm.product_uom)
72 where sm.state = 'done'
73 group by sm.location_dest_id, sm.product_id, sm.product_uom, sm.prodlot_id
75 group by location_id, product_id, prodlot_id
78 def unlink(self, cr, uid, ids, context={}):
79 raise osv.except_osv(_('Error !'), _('You cannot delete any record!'))
82 stock_report_prodlots()
84 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: