value = ''
if not context.get('address'):
return value
+
for address in self.pool.get('res.partner').resolve_o2m_commands_to_record_dicts(
cursor, user, 'address', context['address'], ['type', field], context=context):
if partner_id:
part = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context)
result['owner_name'] = part.name
- result['street'] = part and part.street or False
- result['city'] = part and part.city or False
- result['zip'] = part and part.zip or False
- result['country_id'] = part and part.country_id and part.country_id.id or False
- result['state_id'] = part and part.state_id and part.state_id.id or False
+ result['street'] = part.street or False
+ result['city'] = part.city or False
+ result['zip'] = part.zip or False
+ result['country_id'] = part.country_id.id
+ result['state_id'] = part.state_id.id
return {'value': result}
res_partner_bank()
def address_get(self, cr, uid, ids, adr_pref=None):
if adr_pref is None:
adr_pref = ['default']
- address_ids = self.search(cr, uid, [('parent_id', 'in', ids)])
- address_rec = self.read(cr, uid, address_ids, ['type'])
- res = list((addr['type'],addr['id']) for addr in address_rec)
- adr = dict(res)
+ # retrieve addresses from the partner itself and its children
+ res = []
+ for p in self.browse(cr, uid, ids, context):
+ res.append((p.type, p.id))
+ res.extend((c.type, c.id) for c in p.child_ids)
+ addr = dict(reversed(res))
# get the id of the (first) default address if there is one,
# otherwise get the id of the first address in the list
if res:
- default_address = adr.get('default', res[0][1])
+ default_address = addr.get('default', res[0][1])
else:
default_address = False
result = {}
for a in adr_pref:
- result[a] = adr.get(a, default_address)
+ result[a] = addr.get(a, default_address)
return result
def gen_next_ref(self, cr, uid, ids):