2
# -*- encoding: utf-8 -*-
3
###########################################################################
4
# Module Writen to OpenERP, Open Source Management Solution
5
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
7
###############Credits######################################################
8
# Coded by: Vauxoo C.A.
9
# Planified by: Nhomar Hernandez
10
# Audited by: Vauxoo C.A.
11
#############################################################################
12
# This program is free software: you can redistribute it and/or modify
13
# it under the terms of the GNU Affero General Public License as published by
14
# the Free Software Foundation, either version 3 of the License, or
15
# (at your option) any later version.
17
# This program is distributed in the hope that it will be useful,
18
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
# GNU Affero General Public License for more details.
22
# You should have received a copy of the GNU Affero General Public License
23
# along with this program. If not, see <http://www.gnu.org/licenses/>.
24
################################################################################
27
from osv import fields
28
from tools.translate import _
30
class res_partner_address(osv.osv):
32
def _get_city_name(self, cr, uid, ids, field_name, arg, context=None):
36
for obj in self.browse(cr,uid,ids):
38
res[obj.id] = obj.city_id.name
43
_inherit='res.partner.address'
45
'municipality_id':fields.many2one('res.municipality','Municipality', help="In this field enter the name of the municipality which is associated with the parish", domain= "[('state_id','=',state_id)]"),
46
'parish_id':fields.many2one('res.parish','Parish',help="In this field you enter the parish to which the sector is associated",domain= "[('municipalities_id','=',municipality_id)]" ),
47
'sector_id':fields.many2one('res.sector',string='Sector',required=False,help="in this field select the Sector associated with this Municipality",domain= "[('state_id','=',state_id)]"),
48
'city_id':fields.many2one('res.city',string='City',domain= "[('state_id','=',state_id)]",help="in this field select the city associated with this State"),
49
'city':fields.function(_get_city_name, method=True, type='char', string='City', size=256, domain= "[('state_id','=',state_id)]",store=True),
52
def name_get(self, cr, user, ids, context=None):
57
res = super(res_partner_address,self).name_get(cr, user, ids, context=context)
59
for r in self.read(cr, user, ids, ['name','country_id','state_id','city','municipality_id','parish_id','sector_id','street','street2','partner_id']):
60
if context.get('contact_display', 'contact')=='partner' and r['partner_id']:
61
res.append((r['id'], r['partner_id'][1]))
63
# make a comma-separated list with the following non-empty elements
64
elems = [r['name'], r['country_id'] and r['country_id'][1],r['state_id'] and r['state_id'][1], r['city'], r['municipality_id'] and r['municipality_id'][1],r['parish_id'] and r['parish_id'][1],r['sector_id'] and r['sector_id'][1], r['street'], r['street2'],r['partner_id'] and r['partner_id'][1]]
65
addr = ', '.join(filter(bool, elems))
66
if (context.get('contact_display', 'contact')=='partner_address') and r['partner_id']:
67
res.append((r['id'], "%s: %s" % (r['partner_id'][1], addr or '/')))
69
res.append((r['id'], addr or '/'))