1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
22 from osv import fields,osv
25 class report_workcenter_load(osv.osv):
26 _name="report.workcenter.load"
27 _description="Work Center Load"
31 'name': fields.char('Week', size=64, required=True),
32 'workcenter_id': fields.many2one('mrp.workcenter', 'Work Center', required=True),
33 'cycle': fields.float('Nbr of cycle'),
34 'hour': fields.float('Nbr of hour'),
39 create or replace view report_workcenter_load as (
42 to_char(p.date_planned,'YYYY:mm:dd') as name,
44 SUM(wl.cycle) AS cycle,
45 wl.workcenter_id as workcenter_id
47 mrp_production_workcenter_line wl
48 LEFT JOIN mrp_production p
49 ON p.id = wl.production_id
52 to_char(p.date_planned,'YYYY:mm:dd')
55 report_workcenter_load()
58 class report_mrp_inout(osv.osv):
59 _name="report.mrp.inout"
60 _description="Stock value variation"
65 'date': fields.char('Week', size=64, required=True),
66 'value': fields.float('Stock value', required=True, digits=(16,2)),
71 create or replace view report_mrp_inout as (
74 to_char(sm.date,'YYYY:IW') as date,
75 sum(case when (sl.usage='internal') then
76 pt.standard_price * sm.product_qty
79 end - case when (sl2.usage='internal') then
80 pt.standard_price * sm.product_qty
86 left join product_product pp
87 on (pp.id = sm.product_id)
88 left join product_template pt
89 on (pt.id = pp.product_tmpl_id)
90 left join stock_location sl
91 on ( sl.id = sm.location_id)
92 left join stock_location sl2
93 on ( sl2.id = sm.location_dest_id)
95 sm.state in ('waiting','confirmed','assigned')
97 to_char(sm.date,'YYYY:IW')
103 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: