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
##############################################################################
21
from osv import fields,osv
24
class report_stock_picking(osv.osv):
25
_name = "report.stock.picking"
26
_description = "Stock Picking Report"
29
'year': fields.char('Year',size=64,required=False, readonly=True),
30
'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), ('05','May'), ('06','June'),
31
('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')],'Month',readonly=True),
32
'day': fields.char('Day', size=128, readonly=True),
33
'nbr': fields.integer('# of Lines', readonly=True),
34
'nbp': fields.integer('# of Picking', readonly=True),
35
'partner_id':fields.many2one('res.partner', 'Partner', readonly=True),
36
'product_qty': fields.float('# of Products', readonly=True),
37
'product_uos_qty': fields.float('# of Products', readonly=True),
38
'product_id': fields.many2one('product.product', 'Product', readonly=True),
39
'date': fields.date('Date', readonly=True),
40
'avg_days_to_deliver': fields.float('Avg Days to Deliver', digits=(16,2), readonly=True, group_operator="avg",
41
help="Number of Avg Days to deliver"),
42
'state': fields.selection([('draft', 'Draft'),('auto', 'Waiting'),('confirmed', 'Confirmed'),('assigned', 'Available'),('done', 'Done'),('cancel', 'Cancelled')], 'State'),
43
'type': fields.selection([('out', 'Sending Goods'), ('in', 'Getting Goods'), ('internal', 'Internal'), ('delivery', 'Delivery')], 'Shipping Type', required=True),
44
'company_id': fields.many2one('res.company', 'Company', readonly=True),
45
'invoice_state': fields.selection([
46
("invoiced", "Invoiced"),
47
("2binvoiced", "To Be Invoiced"),
48
("none", "Not from Picking")], "Invoice Status",readonly=True),
49
'min_date': fields.date('Expected Date',help="Expected date for Picking. Default it takes current date"),
50
'order_date': fields.date('Order Date', help="Date of Order"),
51
'date_done': fields.date('Date Done', help="Date of completion"),
52
'location_id': fields.many2one('stock.location', 'Source Location', help="Sets a location if you produce at a fixed location. This can be a partner location if you subcontract the manufacturing operations."),
53
'location_dest_id': fields.many2one('stock.location', 'Dest. Location', help="Location where the system will stock the finished products."),
54
'max_date': fields.date('Max.Expected Date'),
55
'product_uos': fields.many2one('product.uom', 'Product UOS'),
56
'product_uom': fields.many2one('product.uom', 'Product UOM'),
59
tools.drop_view_if_exists(cr, 'report_stock_picking')
61
create or replace view report_stock_picking as (
64
date_trunc('day',sp.min_date) as min_date,
65
date_trunc('day',sp.date) as order_date,
66
date_trunc('day',sp.date_done) as date_done,
67
date_trunc('day',sp.max_date) as max_date,
68
to_char(sp.create_date, 'YYYY') as year,
69
to_char(sp.create_date, 'MM') as month,
70
to_char(sp.create_date, 'YYYY-MM-DD') as day,
71
sp.address_id as partner_id,
72
to_date(to_char(sp.create_date, 'MM-dd-YYYY'),'MM-dd-YYYY') as date,
74
count(distinct sp.id) as nbp,
75
sum(sm.product_qty) as product_qty,
76
sum(sm.product_uos_qty) as product_uos_qty,
77
sm.product_id as product_id,
78
sm.location_dest_id as location_dest_id,
79
sm.location_id as location_id,
84
sp.company_id as company_id,
85
avg(extract('epoch' from (sp.date_done-sp.create_date)))/(3600*24) as avg_days_to_deliver,
88
left join stock_picking as sp ON (sm.picking_id=sp.id)
93
to_char(sp.create_date, 'YYYY'),
96
to_char(sp.create_date, 'MM'),
97
to_char(sp.create_date, 'YYYY-MM-DD'),
100
date_trunc('day',sp.min_date),
101
date_trunc('day',sp.date),
102
date_trunc('day',sp.date_done),
103
date_trunc('day',sp.max_date),
109
report_stock_picking()
110
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: