1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# Copyright (c) 2008 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved.
5
# Jordi Esteve <jesteve@zikzakmedia.com>
7
# WARNING: This program as such is intended to be used by professional
8
# programmers who take the whole responsability of assessing all potential
9
# consequences resulting from its eventual inadequacies and bugs
10
# End users who are looking for a ready-to-use solution with commercial
11
# garantees and support are strongly adviced to contract a Free Software
14
# This program is Free Software; you can redistribute it and/or
15
# modify it under the terms of the GNU General Public License
16
# as published by the Free Software Foundation; either version 2
17
# of the License, or (at your option) any later version.
19
# This program is distributed in the hope that it will be useful,
20
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
# GNU General Public License for more details.
24
# You should have received a copy of the GNU General Public License
25
# along with this program; if not, write to the Free Software
26
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
35
cpostal_end_form = '''<?xml version="1.0" encoding="utf-8"?>
36
<form string="Códigos postales">
37
<separator string="Resultado:" colspan="4"/>
38
<label string="Se han asociado los municipios y provincias a los códigos postales del Estado Español." colspan="4" align="0.0"/>
39
<label string="Permite rellenar automáticamente los campos ciudad y provincia del formulario de empresa y contacto a partir del código postal." colspan="4" align="0.0"/>
42
class l10n_ES_crear_cpostal(wizard.interface):
43
def _crear_cpostal(self, cr, uid, data, context):
44
from municipios_cpostal import cod_postales
45
pool = pooler.get_pool(cr.dbname)
46
idc = pool.get('res.country').search(cr, uid, [('code', '=', 'ES'),])
50
for m in cod_postales:
51
ids = pool.get('res.country.state').search(cr, uid, [('country_id', '=', idc), ('code', '=', m[0][:2]),])
53
ir.ir_set(cr, uid, 'default', 'zip='+m[0], 'state_id', [('res.partner.address', False)], ids[0])
54
ir.ir_set(cr, uid, 'default', 'zip='+m[0], 'city', [('res.partner.address', False)], m[1])
59
'actions': [_crear_cpostal],
62
'arch':cpostal_end_form,
64
'state':[('end', 'Aceptar', 'gtk-ok'),]
70
l10n_ES_crear_cpostal('l10n_ES_toponyms.crear_cpostal')