~serpent-consulting-services/openerp-usa/shipping_api_6-1

« back to all changes in this revision

Viewing changes to shipping_api/stock_packages.py

  • Committer: npgllc
  • Date: 2012-07-26 11:13:58 UTC
  • mfrom: (59.1.1 PackingSlip)
  • Revision ID: npgllc-20120726111358-eldlob3fcod5sv18
Added Packing Slip High Value Shipment for UPS

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
class stock_packages(osv.osv):
26
26
    _name = "stock.packages"
27
27
    _rec_name = "packge_no"
 
28
    
 
29
    def _button_visibility(self, cr, uid, ids, field_name, arg, context=None):
 
30
        result = {}
 
31
        for package in self.browse(cr, uid, ids, context=context):
 
32
            result[package.id] = True
 
33
            if package.pick_id.ship_state in ['read_pick','shipped','delivered', 'draft', 'cancelled']:
 
34
                result[package.id] = False
 
35
        return result
 
36
    
28
37
    _columns = {
29
38
        'packge_no': fields.integer('Package Number', help='The number of the package associated with the delivery.\
30
39
                                    Example: 3 packages may be associated with a delivery.'),
82
91
        'ship_message': fields.text('Status Message'),
83
92
        'tracking_url': fields.char('Tracking URL', size=512),
84
93
        'package_type_id': fields.many2one('logistic.company.package.type', 'Package Type'),
 
94
        'show_button': fields.function(_button_visibility, method=True, type='boolean', string='Show'),
 
95
        'package_item_ids' : fields.one2many('shipment.package.item','package_id','Package Items')
85
96
        }
86
97
    
87
98
    _defaults = {
101
112
                },
102
113
            'nodestroy': True
103
114
            }
 
115
    
 
116
    def print_packing_slips(self, cr, uid, ids, context=None):
 
117
        if not ids: return []
 
118
        return {
 
119
            'type': 'ir.actions.report.xml',
 
120
            'report_name': 'package.packing.slip.print',
 
121
            'datas': {
 
122
                'model': 'stock.packages',
 
123
                'id': ids and ids[0] or False,
 
124
                'ids': ids,
 
125
                'report_type': 'pdf'
 
126
                },
 
127
            'nodestroy': True
 
128
            }
104
129
        
105
130
    def onchange_packge_no(self, cr, uid, ids, line_ids, packge_no, context=None):
106
131
        """
139
164
    
140
165
stock_packages()
141
166
 
 
167
class shipment_package_item(osv.osv):
 
168
    _name = 'shipment.package.item'
 
169
    _description = 'Shipment Package Item'
 
170
    _rec_name = 'product_id'
 
171
    
 
172
    def onchange_product_id(self, cr, uid, ids, product_id):
 
173
        res = {'value':{'name':'','cost':0.0}}
 
174
        product_obj = self.pool.get('product.product')
 
175
        if not product_id:
 
176
            return res
 
177
        prod = product_obj.browse(cr, uid, product_id)
 
178
        res['value'] = {
 
179
            'cost' : prod.list_price or 0.0
 
180
        }
 
181
        return res
 
182
        
 
183
    _columns = {
 
184
        'product_id': fields.many2one('product.product','Product', required=True),
 
185
        'cost': fields.float('Value',required=True),
 
186
        'package_id': fields.many2one('stock.packages','Package'),
 
187
        'prod_lot_id': fields.many2one('stock.production.lot', 'Production Lot')
 
188
    }
 
189
    
 
190
shipment_package_item()
 
191
 
142
192
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 
 
b'\\ No newline at end of file'