Merge lp:~acysos-team/openerp-spain/openerp-spain-6.0-cityupdate into lp:~openerp-spain-team/openerp-spain/6.0

Proposed by Ignacio Ibeas (www.acysos.com) on 2013-04-30
Status: Merged
Merged at revision: 344
Proposed branch: lp:~acysos-team/openerp-spain/openerp-spain-6.0-cityupdate
Merge into: lp:~openerp-spain-team/openerp-spain/6.0
Diff against target: 75 lines (+19/-12)
2 files modified
l10n_es_toponyms/__openerp__.py (+6/-2)
l10n_es_toponyms/l10n_es_toponyms.py (+13/-10)
To merge this branch: bzr merge lp:~acysos-team/openerp-spain/openerp-spain-6.0-cityupdate
Reviewer Review Type Date Requested Status
Pedro Manuel Baeza 2013-04-30 Approve on 2013-05-01
Review via email: mp+161655@code.launchpad.net

Description of the change

Fix para poder ser utilizado con el modulo city portado a la 6.0.

El módulo city para la 6.0 esta en nuestro repositorio (http://launchpad.net/acysos) ya que extra-6.0 ya no se utiliza. El código es el mismo que la versión 6.1, excepto la parte relevante a company que cambia, permitiendo un mantenimiento más sencillo.

Si alguien se le ocurre un mejor sitio donde poner el módulo city que me indique.

Saludos,
Ignacio Ibeas

To post a comment you must log in.
Pedro Manuel Baeza (pedro.baeza) wrote :

Haciendo revisión de código, parece todo correcto.

No he realizado tests.

review: Approve

Yo si he hecho pruebas y entra en producción hoy mismo en uno de mis clientes.

Realizo el merge.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'l10n_es_toponyms/__openerp__.py'
2--- l10n_es_toponyms/__openerp__.py 2011-08-31 11:21:23 +0000
3+++ l10n_es_toponyms/__openerp__.py 2013-04-30 17:30:02 +0000
4@@ -4,6 +4,10 @@
5 # OpenERP, Open Source Management Solution
6 # Copyright (c) 2009 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved.
7 # Jordi Esteve <jesteve@zikzakmedia.com>
8+# Copyright (c) 2013 Servicios Baeza (http://www.serviciosbaeza.com/) All Rights Reserved.
9+# Pedro Manuel Baeza <pedro.baeza@gmail.com>
10+# Copyright (c) 2013 Acysos S.L. (http://acysos.com) All Rights Reserved.
11+# Ignacio Ibeas <ignacio@acysos.com>
12 # $Id$
13 #
14 # This program is free software: you can redistribute it and/or modify
15@@ -24,8 +28,8 @@
16 {
17 "name" : "Topónimos del Estado español",
18 "version" : "1.0",
19- "author" : "Zikzakmedia SL",
20- "website" : "www.zikzakmedia.com",
21+ "author" : "Zikzakmedia SL, Servicios Baeza, Acysos S.L.",
22+ "website" : "www.zikzakmedia.com, www.serviciosbaeza.com, www.acysos.com ",
23 "category" : "Localisation/Europe",
24 "description": """Provincias, municipios y códigos postales del Estado Español
25
26
27=== modified file 'l10n_es_toponyms/l10n_es_toponyms.py'
28--- l10n_es_toponyms/l10n_es_toponyms.py 2011-08-29 15:11:11 +0000
29+++ l10n_es_toponyms/l10n_es_toponyms.py 2013-04-30 17:30:02 +0000
30@@ -4,6 +4,10 @@
31 # OpenERP, Open Source Management Solution
32 # Copyright (c) 2009 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved.
33 # Jordi Esteve <jesteve@zikzakmedia.com>
34+# Copyright (c) 2013 Servicios Baeza (http://www.serviciosbaeza.com/) All Rights Reserved.
35+# Pedro Manuel Baeza <pedro.baeza@gmail.com>
36+# Copyright (c) 2013 Acysos S.L. (http://acysos.com) All Rights Reserved.
37+# Ignacio Ibeas <ignacio@acysos.com>
38 # $Id$
39 #
40 # This program is free software: you can redistribute it and/or modify
41@@ -93,15 +97,16 @@
42
43 def _recover_zipcodes(self, cr, uid, context):
44 # Recovers the location data (city info) from the zip code there was in the partner addresses before installing the city module
45- cr.execute("select id, zip from res_partner_address where location IS NULL")
46- zipcodes = cr.dictfetchall()
47+ address_obj = self.pool.get('res.partner.address')
48+ city_obj = self.pool.get('city.city')
49+ addresses_ids = address_obj.search(cr, uid, [('city_id','=', False)])
50+ addresses = address_obj.read(cr, uid, addresses_ids, ['zip'])
51 cont = 0
52- for zipcode in zipcodes:
53- if zipcode['zip']:
54- cr.execute("select id from city_city where zipcode = '%s'" %zipcode['zip'])
55- city_id = cr.fetchall()
56- if len(city_id) > 0:
57- cr.execute("update res_partner_address SET location = %i WHERE id = %i" %(city_id[0][0], zipcode['id']))
58+ for address in addresses:
59+ if address['zip']:
60+ city_id = city_obj.search(cr, uid, [('zip', '=', address['zip'])])
61+ if len(city_id):
62+ address_obj.write(cr, uid, address['id'], {'city_id' : city_id[0]})
63 cont += 1
64 return cont
65
66@@ -121,9 +126,7 @@
67 tools.convert_xml_import(cr, 'l10n_es_toponyms', fp, idref, 'init', noupdate=True)
68 if res['city_info_recover'] == 'yes':
69 res= self._recover_zipcodes(cr, uid, context)
70- #print res
71 cr.commit()
72- cr.close()
73 return {}
74
75 def execute(self, cr, uid, ids, context=None):