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
##############################################################################
24
from report import report_sxw
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({
33
'get_address': self._get_address,
34
'get_address_ship':self._get_address_ship
37
def _get_address(self,data):
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,))
47
add=self.cr.dictfetchall()
50
def _get_address_ship(self,data):
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,))
60
ship=self.cr.dictfetchall()
63
# def _sum_total(self,data):
64
# print "======data=======",data
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
74
report_sxw.report_sxw('report.sale.shipping','stock.picking','addons/sale/report/shipping.rml',parser=shipping)