~serpent-consulting-services/openerp-usa/fix-shipping_api_ups_cc

« back to all changes in this revision

Viewing changes to shipping_api_ups/sale.py

  • Committer: npgllc
  • Date: 2012-08-02 17:13:27 UTC
  • Revision ID: npgllc-20120802171327-2xgyyjjb5d1kx26y
Removed all the 6.0 compatible modules

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) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
6
 
#    Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
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
 
from osv import fields, osv
24
 
 
25
 
class sale_order(osv.osv):
26
 
    _inherit="sale.order"
27
 
    
28
 
    def action_ship_create(self, cr, uid, ids, *args):
29
 
        result = super(sale_order, self).action_ship_create(cr, uid, ids, *args)
30
 
        if result:
31
 
            for sale in self.browse(cr, uid, ids):
32
 
                pick_obj = self.pool.get('stock.picking')
33
 
                if sale.ship_company_code == 'ups':
34
 
                    pick_ids = pick_obj.search(cr, uid, [('sale_id', '=', sale.id), ('type', '=', 'out')])
35
 
                    if pick_ids:
36
 
                        vals = {
37
 
                            'ship_company_code': 'ups',
38
 
                            'logis_company': sale.logis_company and sale.logis_company.id or False,
39
 
                            'shipper': sale.ups_shipper_id and sale.ups_shipper_id.id or False,
40
 
                            'ups_service': sale.ups_service_id and sale.ups_service_id.id or False,
41
 
                            'ups_pickup_type': sale.ups_pickup_type,
42
 
                            'ups_packaging_type': sale.ups_packaging_type and sale.ups_packaging_type.id or False
43
 
                            }
44
 
                        pick_obj.write(cr, uid, pick_ids, vals)
45
 
                else:
46
 
                    pick_ids = pick_obj.search(cr, uid, [('sale_id', '=', sale.id), ('type', '=', 'out')])
47
 
                    if pick_ids:
48
 
                        pick_obj.write(cr, uid, pick_ids, {'shipper': False, 'ups_service': False}, context=None)
49
 
        return result
50
 
    
51
 
    def _get_company_code(self, cr, user, context=None):
52
 
        res =  super(sale_order, self)._get_company_code(cr, user, context=context)
53
 
        res.append(('ups', 'UPS'))
54
 
        return res
55
 
    
56
 
    _columns= {
57
 
        'payment_method':fields.selection([
58
 
            ('cc_pre_auth', 'Credit Card – PreAuthorized'),
59
 
            ('invoice', 'Invoice'),
60
 
            ('cod', 'COD'),
61
 
            ('p_i_a', 'Pay In Advance'),
62
 
            ('pay_pal', 'Paypal'),
63
 
            ('no_charge', 'No Charge')], 'Payment Method'),
64
 
        'ship_company_code': fields.selection(_get_company_code, 'Ship Company', method=True, size=64),
65
 
        'ups_shipper_id': fields.many2one('ups.account.shipping', 'Shipper'),
66
 
        'ups_service_id': fields.many2one('ups.shipping.service.type', 'Service Type'),
67
 
        'ups_pickup_type': fields.selection([
68
 
            ('01', 'Daily Pickup'),
69
 
            ('03', 'Customer Counter'),
70
 
            ('06', 'One Time Pickup'),
71
 
            ('07', 'On Call Air'),
72
 
            ('11', 'Suggested Retail Rates'),
73
 
            ('19', 'Letter Center'),
74
 
            ('20', 'Air Service Center'),
75
 
            ],'Pickup Type'),
76
 
        'ups_packaging_type': fields.many2one('shipping.package.type','Packaging Type')
77
 
    }
78
 
    
79
 
sale_order()
80
 
 
81
 
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: