diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 5d453686f97..253e8e52fc1 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -316,7 +316,7 @@ class purchase_order(osv.osv): 'picking_type_id': fields.many2one('stock.picking.type', 'Deliver To', help="This will determine picking type of incoming shipment", required=True, states={'confirmed': [('readonly', True)], 'approved': [('readonly', True)], 'done': [('readonly', True)]}), 'related_location_id': fields.related('picking_type_id', 'default_location_dest_id', type='many2one', relation='stock.location', string="Related location", store=True), - 'related_usage': fields.related('location_id', 'usage', type='char'), + 'related_usage': fields.related('location_id', 'usage', type='char', readonly=True), 'shipment_count': fields.function(_count_all, type='integer', string='Incoming Shipments', multi=True), 'invoice_count': fields.function(_count_all, type='integer', string='Invoices', multi=True) } @@ -421,6 +421,13 @@ class purchase_order(osv.osv): value.update({'related_location_id': picktype.default_location_dest_id.id}) return {'value': value} + def onchange_location_id(self, cr, uid, ids, location_id, context=None): + value = {'related_usage': False} + if location_id: + value['related_usage'] = self.pool['stock.location'].browse(cr, uid, location_id, context=context).usage + return {'value': value} + + def onchange_partner_id(self, cr, uid, ids, partner_id, context=None): partner = self.pool.get('res.partner') if not partner_id: diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 2b22a23890a..cf55d63ae7c 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -274,7 +274,7 @@ - +