~openerp-spain-team/openerp-spain/5.0-git

« back to all changes in this revision

Viewing changes to l10n_es_extras/l10n_ES_toponyms/l10n_ES_cpostal.py

  • Committer: Jordi Esteve
  • Date: 2008-11-22 18:10:47 UTC
  • mto: (81.1.11)
  • mto: This revision was merged to the branch mainline in revision 82.
  • Revision ID: git-v1:17b2f2e18f8242439b99084ca0496b60ec99e90d
Actualización módulo l10n_ES_toponyms para 5.0 con nuevo asistente de configuración: versiones oficiales, castellanas o ambas de provincias, creación de valores por defecto según módulo city esté instalado o no, ... Arreglados pequeños bugs de account_paytype y l10n_ES_remesas

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- encoding: utf-8 -*-
2
 
##############################################################################
3
 
#
4
 
# Copyright (c) 2008 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved.
5
 
#                    Jordi Esteve <jesteve@zikzakmedia.com>
6
 
#
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
12
 
# Service Company
13
 
#
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.
18
 
#
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.
23
 
#
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.
27
 
#
28
 
 
29
 
import ir
30
 
import wizard
31
 
import pooler
32
 
import codecs
33
 
import tools
34
 
 
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"/>
40
 
</form>'''
41
 
 
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'),])
47
 
        if not idc:
48
 
            return
49
 
        idc = idc[0]
50
 
        for m in cod_postales:
51
 
            ids = pool.get('res.country.state').search(cr, uid, [('country_id', '=', idc), ('code', '=', m[0][:2]),])
52
 
            if ids:
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])
55
 
        return {}
56
 
 
57
 
    states = {
58
 
        'init': {
59
 
            'actions': [_crear_cpostal],
60
 
            'result': {
61
 
                'type':'form',
62
 
                'arch':cpostal_end_form,
63
 
                'fields': {},
64
 
                'state':[('end', 'Aceptar', 'gtk-ok'),]
65
 
            }
66
 
        }
67
 
 
68
 
    }
69
 
 
70
 
l10n_ES_crear_cpostal('l10n_ES_toponyms.crear_cpostal')