diff --git a/openerp/addons/base/res/res_partner.py b/openerp/addons/base/res/res_partner.py index c74fb890515..99945b00ce2 100644 --- a/openerp/addons/base/res/res_partner.py +++ b/openerp/addons/base/res/res_partner.py @@ -405,7 +405,7 @@ class res_partner(osv.osv): ('name','=','main_partner')])[0], ).res_id - def _display_address(self, cr, uid, address, context=None): + def _display_address(self, cr, uid, address,type ,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. @@ -415,10 +415,17 @@ class res_partner(osv.osv): if not country is specified) :rtype: string ''' + + if type: + if address.is_company=='partner' and address.child_ids: + for child_id in address.child_ids: + if child_id.type==type: + address=child_id + + # get the information that will be injected into the display format # 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 + '%(street)s\n%(street2)s\n%(city)s,%(state_code)s %(zip)s' args = { 'state_code': address.state_id and address.state_id.code or '', 'state_name': address.state_id and address.state_id.name or '', diff --git a/openerp/report/report_sxw.py b/openerp/report/report_sxw.py index 9764a64a3f6..f1eb981b32c 100644 --- a/openerp/report/report_sxw.py +++ b/openerp/report/report_sxw.py @@ -320,8 +320,8 @@ class rml_parse(object): res='%s %s'%(currency_obj.symbol, res) return res - def display_address(self, address_browse_record): - return self.pool.get('res.partner')._display_address(self.cr, self.uid, address_browse_record) + def display_address(self, address_browse_record,type=''): + return self.pool.get('res.partner')._display_address(self.cr, self.uid, address_browse_record,type) def repeatIn(self, lst, name,nodes_parent=False): ret_lst = []