~jgrandguillaume-c2c/openobject-addons/multi-company-cost-price

« back to all changes in this revision

Viewing changes to mrp/report/mrp_production_order.py

  • Committer: Joël Grand-Guillaume
  • Date: 2010-04-08 09:00:10 UTC
  • mfrom: (2533.3.664)
  • Revision ID: joel.grandguillaume@camptocamp.com-20100408090010-c0pqjan341s18bxs
[MRG] Merge from last trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    OpenERP, Open Source Management Solution
 
5
#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
 
6
#
 
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.
 
11
#
 
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.
 
16
#
 
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/>.
 
19
#
 
20
##############################################################################
 
21
from osv import fields,osv
 
22
import tools
 
23
 
 
24
 
 
25
class mrp_production_order(osv.osv):
 
26
    _name = "mrp.production.order"
 
27
    _description = "Production Order Report"
 
28
    _auto = False
 
29
    _columns = {
 
30
        'name': fields.char('Year',size=64,required=False, readonly=True),
 
31
        'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), ('05','May'), ('06','June'),
 
32
                                  ('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')],'Month',readonly=True),
 
33
        'reference': fields.char('Reference', size=64, required=True),
 
34
        'origin': fields.char('Source Document', size=64),
 
35
        'nbr': fields.integer('# of Orders', readonly=True),
 
36
        'product_id': fields.many2one('product.product', 'Product', required=True, domain=[('type','<>','service')]),
 
37
        'state': fields.selection([('draft','Draft'),('picking_except', 'Picking Exception'),('confirmed','Waiting Goods'),('ready','Ready to Produce'),('in_production','In Production'),('cancel','Cancelled'),('done','Done')],'State', readonly=True),
 
38
        'scheduled_date':fields.date('Scheduled Date'),
 
39
        'location_src_id': fields.many2one('stock.location', 'Raw Materials Location', required=True),
 
40
        'location_dest_id': fields.many2one('stock.location', 'Finished Products Location', required=True),
 
41
 
 
42
 
 
43
    }
 
44
    def init(self, cr):
 
45
        tools.drop_view_if_exists(cr, 'mrp_production_order')
 
46
        cr.execute("""
 
47
            create or replace view mrp_production_order as (
 
48
                select
 
49
                    min(c.id) as id,
 
50
                    to_char(c.create_date, 'YYYY') as name,
 
51
                    to_char(c.create_date, 'MM') as month,
 
52
                    c.state,
 
53
                    c.product_id,
 
54
                    count(*) as nbr,
 
55
                    to_date(to_char(c.date_planned, 'dd-MM-YYYY'),'dd-MM-YYYY') as scheduled_date,
 
56
                    c.name as reference,
 
57
                    c.origin,
 
58
                    c.location_src_id,
 
59
                    c.location_dest_id
 
60
                from
 
61
                    mrp_production c
 
62
                group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state,c.product_id,to_date(to_char(c.date_planned, 'dd-MM-YYYY'),'dd-MM-YYYY'),c.name,c.location_src_id,c.location_dest_id,c.origin
 
63
            )""")
 
64
mrp_production_order()
 
65
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 
66