~openerp-community-committers/openobject-addons/5.0

« back to all changes in this revision

Viewing changes to sale/report/shipping.py

  • Committer: Fabien Pinckaers
  • Date: 2009-01-15 17:37:46 UTC
  • Revision ID: fp@tinyerp.com-20090115173746-pf9k1ld5bi4j2pag
modifs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- encoding: utf-8 -*-
2
 
##############################################################################
3
 
#
4
 
#    OpenERP, Open Source Management Solution
5
 
#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6
 
#    $Id$
7
 
#
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.
12
 
#
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.
17
 
#
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/>.
20
 
#
21
 
##############################################################################
22
 
 
23
 
import time
24
 
from report import report_sxw
25
 
from osv import osv
26
 
import pooler
27
 
 
28
 
class shipping(report_sxw.rml_parse):
29
 
    def __init__(self, cr, uid, name, context):
30
 
        super(shipping, self).__init__(cr, uid, name, context)
31
 
        self.localcontext.update({
32
 
            'time': time,
33
 
            'get_address': self._get_address,
34
 
            'get_address_ship':self._get_address_ship
35
 
        })
36
 
 
37
 
    def _get_address(self,data):
38
 
 
39
 
         self.cr.execute("select sp.id,sp.origin,sp.address_id,so.partner_id,rp.name as name2,so.partner_invoice_id,rpa.name,rpa.street as Street,rpa.city ,rpa.zip,rc.name as country " \
40
 
                         "from sale_order as so, stock_picking as sp,res_partner rp,res_partner_address as rpa,res_country as rc " \
41
 
                         "where sp.origin=so.name " \
42
 
                         "and so.partner_id=rp.id " \
43
 
                         "and so.partner_invoice_id=rpa.id  " \
44
 
                         "and rpa.country_id=rc.id " \
45
 
                         "and sp.id=%s", (data.id,))
46
 
 
47
 
         add=self.cr.dictfetchall()
48
 
         return add
49
 
 
50
 
    def _get_address_ship(self,data):
51
 
 
52
 
         self.cr.execute("select sp.id,sp.origin,sp.address_id,so.partner_id,rp.name as name2,so.partner_shipping_id,rpa.name,rpa.street as Street,rpa.city ,rpa.zip,rc.name as country " \
53
 
                         "from sale_order as so, stock_picking as sp,res_partner rp,res_partner_address as rpa,res_country as rc " \
54
 
                         "where sp.origin=so.name " \
55
 
                         "and so.partner_id=rp.id " \
56
 
                         "and so.partner_shipping_id=rpa.id  " \
57
 
                         "and rpa.country_id=rc.id " \
58
 
                         "and sp.id=%s", (data.id,))
59
 
 
60
 
         ship=self.cr.dictfetchall()
61
 
         return ship
62
 
 
63
 
#    def _sum_total(self,data):
64
 
#        print "======data=======",data
65
 
 
66
 
#        self.cr.execute("SELECT sum(pt.list_price*sm.product_qty) FROM stock_picking as sp "\
67
 
#                        "LEFT JOIN  stock_move sm ON (sp.id = sm.picking_id) "\
68
 
#                        "LEFT JOIN  product_product pp ON (sm.product_id = pp.id) "\
69
 
#                        "LEFT JOIN  product_template pt ON (pp.product_tmpl_id = pt.id) "\
70
 
#                        "WHERE sm.picking_id = %s", (data['id'],))
71
 
#        sum_total = self.cr.fetchone()[0] or 0.00
72
 
#        return True
73
 
 
74
 
report_sxw.report_sxw('report.sale.shipping','stock.picking','addons/sale/report/shipping.rml',parser=shipping)