[IMP]base/res: Move display_address method in res.partner

bzr revid: sbh@tinyerp.com-20120227100530-8xg61062982kyf97
This commit is contained in:
Bhumika (OpenERP)
2012-02-27 15:35:30 +05:30
parent 4bbe96a354
commit fa64c13138
+26
View File
@@ -331,6 +331,32 @@ class res_partner(osv.osv):
model_data.search(cr, uid, [('module','=','base'),
('name','=','main_partner')])[0],
).res_id
def _display_address(self, cr, uid, address, context=None):
'''
The purpose of this function is to build and return an address formatted accordingly to the
standards of the country where it belongs.
:param address: browse record of the res.partner.address to format
:returns: the address formatted in a display that fit its country habits (or the default ones
if not country is specified)
:rtype: string
'''
# get the address format
address_format = address.country_id and address.country_id.address_format or \
'%(street)s\n%(street2)s\n%(city)s,%(state_code)s %(zip)s'
# get the information that will be injected into the display format
args = {
'state_code': address.state_id and address.state_id.code or '',
'state_name': address.state_id and address.state_id.name or '',
'country_code': address.country_id and address.country_id.code or '',
'country_name': address.country_id and address.country_id.name or '',
}
address_field = ['title', 'street', 'street2', 'zip', 'city']
for field in address_field :
args[field] = getattr(address, field) or ''
return address_format % args
res_partner()