1
# -*- coding: utf-8 -*-
2
from osv import osv, fields
4
class res_partner_address(osv.osv):
5
_inherit = 'res.partner.address'
7
def _display_address_custom(self, cr, uid, address, company, context=None):
9
This method is almost identical to the one in base/res/res_partner.py,
10
but it does not print the country if this is equal to the company partner's
11
country, unless we print the company partner's own address.
13
Note that this method has a different signature than the original one,
14
as it passes the company browse record.
16
:param address: browse record of the res.partner.address to format
17
:param company: browse record of the res.company
18
:returns: the address formatted in a display that fit its country habits (or the default ones
19
if not country is specified)
22
# get the address format
23
address_format = address.country_id and address.country_id.address_format or \
24
'%(street)s\n%(street2)s\n%(city)s,%(state_code)s %(zip)s'
25
# get the information that will be injected into the display format
27
'state_code': address.state_id and address.state_id.code or '',
28
'state_name': address.state_id and address.state_id.name or '',
29
'country_code': address.country_id and address.country_id.code or '',
30
'country_name': address.country_id and address.country_id.name or '',
35
if (address.country_id and company and company.partner_id.country and
36
company.partner_id.country.id == address.country_id.id and
37
not (address.partner_id and
38
address.partner_id.id == company.partner_id.id)
40
args['country_name'] = ''
41
# end of custom changes
43
address_field = ['title', 'street', 'street2', 'zip', 'city']
44
for field in address_field :
45
args[field] = getattr(address, field) or ''
47
return address_format % args