[FIX]: Purchase : Updated the code by declaring reception_address_id inside loop
authorRavi Gohil (Open ERP) <rgo@tinyerp.com>
Mon, 12 Mar 2012 12:03:28 +0000 (17:33 +0530)
committerRavi Gohil (Open ERP) <rgo@tinyerp.com>
Mon, 12 Mar 2012 12:03:28 +0000 (17:33 +0530)
lp bug: https://launchpad.net/bugs/916248 fixed

bzr revid: rgo@tinyerp.com-20120312120328-b31rkj78g9yl0h2b

1  2 
addons/purchase/purchase.py

@@@ -433,7 -433,17 +433,17 @@@ class purchase_order(osv.osv)
  
      def action_picking_create(self,cr, uid, ids, *args):
          picking_id = False
 -        reception_address_id = False
          for order in self.browse(cr, uid, ids):
++            reception_address_id = False
+             if order.dest_address_id:
+                 reception_address_id = order.dest_address_id.id
+             elif order.warehouse_id and order.warehouse_id.partner_address_id:
+                 reception_address_id = order.warehouse_id.partner_address_id.id
+             else:
+                 if order.company_id.partner_id.address:
+                     addresses_default = [address.id for address in order.company_id.partner_id.address if address.type == 'default']
+                     addresses_delivery = [address.id for address in order.company_id.partner_id.address if address.type == 'delivery']
+                     reception_address_id = (addresses_delivery and addresses_delivery[0]) or (addresses_default and addresses_default[0]) or False
              loc_id = order.partner_id.property_stock_supplier.id
              istate = 'none'
              if order.invoice_method=='picking':