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 fields,osv
26 class report_workcenter_load(osv.osv):
27 _name="report.workcenter.load"
28 _description="Workcenter Load"
32 'name': fields.char('Week', size=64, required=True),
33 'workcenter_id': fields.many2one('mrp.workcenter', 'Workcenter', required=True),
34 'cycle': fields.float('Nbr of cycle'),
35 'hour': fields.float('Nbr of hour'),
40 create or replace view report_workcenter_load as (
43 to_char(p.date_planned,'YYYY:IW') as name,
45 SUM(wl.cycle) AS cycle,
46 wl.workcenter_id as workcenter_id
48 mrp_production_workcenter_line wl
49 LEFT JOIN mrp_production p
50 ON p.id = wl.production_id
53 to_char(p.date_planned,'YYYY:IW')
56 report_workcenter_load()
59 class report_mrp_inout(osv.osv):
60 _name="report.mrp.inout"
61 _description="Stock value variation"
66 'date': fields.char('Week', size=64, required=True),
67 'value': fields.float('Stock value', required=True, digits=(16,2)),
72 create or replace view report_mrp_inout as (
75 to_char(sm.date_planned,'YYYY:IW') as date,
76 sum(case when (sl.usage='internal') then
77 pt.standard_price * sm.product_qty
80 end - case when (sl2.usage='internal') then
81 pt.standard_price * sm.product_qty
87 left join product_product pp
88 on (pp.id = sm.product_id)
89 left join product_template pt
90 on (pt.id = pp.product_tmpl_id)
91 left join stock_location sl
92 on ( sl.id = sm.location_id)
93 left join stock_location sl2
94 on ( sl2.id = sm.location_dest_id)
96 sm.state in ('waiting','confirmed','assigned')
98 to_char(sm.date_planned,'YYYY:IW')
104 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: