1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2011 Cubic ERP - Teradata SAC (<http://cubicerp.com>).
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU Affero General Public License as
9
# published by the Free Software Foundation, either version 3 of the
10
# License, or (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU Affero General Public License for more details.
17
# You should have received a copy of the GNU Affero General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
##############################################################################
22
from osv import fields, osv
24
class res_partner_address(osv.osv):
25
_inherit = 'res.partner.address'
26
_name = 'res.partner.address'
29
'province_id': fields.many2one("res.country.province", 'Province', domain="[('state_id','=',state_id)]"),
30
'district_id': fields.many2one("res.country.district", 'District', domain="[('province_id','=',province_id)]"),
31
'address_ref' : fields.char('Address Reference', size=256, help="One or more points used as reference to locate the address"),
34
def name_get(self, cr, user, ids, context=None):
40
for r in self.read(cr, user, ids, ['name','zip','country_id', 'city','partner_id', 'street','state_id','province_id','district_id','address_ref','street2']):
41
if context.get('contact_display', 'contact')=='partner' and r['partner_id']:
42
res.append((r['id'], r['partner_id'][1]))
44
# make a comma-separated list with the following non-empty elements
45
elems = [r['name'], r['street'], r['street2'], r['district_id'] and r['district_id'][1], r['province_id'] and r['province_id'][1], r['address_ref'] ]
46
addr = ', '.join(filter(bool, elems))
47
if (context.get('contact_display', 'contact')=='partner_address') and r['partner_id']:
48
res.append((r['id'], "%s: %s" % (r['partner_id'][1], addr or '/')))
50
res.append((r['id'], addr or '/'))