Merge lp:~agilebg/openobject-italia/7.0-bug-1239610-elbati into lp:~openobject-italia-core-devs/openobject-italia/italian-addons-7.0

Proposed by Lorenzo Battistini
Status: Merged
Merged at revision: 224
Proposed branch: lp:~agilebg/openobject-italia/7.0-bug-1239610-elbati
Merge into: lp:~openobject-italia-core-devs/openobject-italia/italian-addons-7.0
Diff against target: 147 lines (+48/-25)
1 file modified
l10n_it_base/partner/partner.py (+48/-25)
To merge this branch: bzr merge lp:~agilebg/openobject-italia/7.0-bug-1239610-elbati
Reviewer Review Type Date Requested Status
bruno bottacini (community) Approve
OpenERP Italia core devs Pending
Review via email: mp+191239@code.launchpad.net

Description of the change

PEP8 and fix for bug 1239610

The fix is made by this commit http://bazaar.launchpad.net/~agilebg/openobject-italia/7.0-bug-1239610-elbati/revision/224

'=ilike' means 'use the SQL ilike'. So, the search is case insensitive

To post a comment you must log in.
Revision history for this message
bruno bottacini (bruno-bottacini) wrote :

il problema non si presenta più

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'l10n_it_base/partner/partner.py'
2--- l10n_it_base/partner/partner.py 2013-03-01 09:25:20 +0000
3+++ l10n_it_base/partner/partner.py 2013-10-15 16:02:01 +0000
4@@ -1,19 +1,19 @@
5 # -*- encoding: utf-8 -*-
6 ##############################################################################
7-#
8-# Copyright (C) 2010 OpenERP Italian Community (<http://www.openerp-italia.org>).
9-# All Rights Reserved
10-# $Id$
11+#
12+# Copyright (C) 2010 OpenERP Italian Community
13+# (<http://www.openerp-italia.org>).
14+# Copyright (C) 2010 Associazione OpenERP Italia.
15 #
16 # This program is free software: you can redistribute it and/or modify
17-# it under the terms of the GNU Affero General Public License as published by
18-# the Free Software Foundation, either version 3 of the License, or
19+# it under the terms of the GNU Affero General Public License as published
20+# by the Free Software Foundation, either version 3 of the License, or
21 # (at your option) any later version.
22 #
23 # This program is distributed in the hope that it will be useful,
24 # but WITHOUT ANY WARRANTY; without even the implied warranty of
25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26-# GNU General Public License for more details.
27+# GNU Affero General Public License for more details.
28 #
29 # You should have received a copy of the GNU General Public License
30 # along with this program. If not, see <http://www.gnu.org/licenses/>.
31@@ -24,40 +24,52 @@
32 from osv import fields
33 from tools.translate import _
34
35+
36 class res_region(osv.osv):
37 _name = 'res.region'
38 _description = 'Region'
39 _columns = {
40- 'name': fields.char('Region Name', size=64, help='The full name of the region.', required=True),
41+ 'name': fields.char(
42+ 'Region Name', size=64, help='The full name of the region.',
43+ required=True),
44 'country_id': fields.many2one('res.country', 'Country'),
45 }
46 res_region()
47
48+
49 class res_province(osv.osv):
50 _name = 'res.province'
51 _description = 'Province'
52 _columns = {
53- 'name': fields.char('Province Name', size=64, help='The full name of the province.', required=True),
54- 'code': fields.char('Province Code', size=2, help='The province code in two chars.',required=True),
55- 'region': fields.many2one('res.region','Region'),
56+ 'name': fields.char(
57+ 'Province Name', size=64, help='The full name of the province.',
58+ required=True),
59+ 'code': fields.char(
60+ 'Province Code', size=2, help='The province code in two chars.',
61+ required=True),
62+ 'region': fields.many2one('res.region', 'Region'),
63 }
64
65 res_province()
66
67+
68 class res_city(osv.osv):
69 _name = 'res.city'
70 _description = 'City'
71 _columns = {
72 'name': fields.char('City', size=64, required=True),
73- 'province_id': fields.many2one('res.province','Province'),
74+ 'province_id': fields.many2one('res.province', 'Province'),
75 'zip': fields.char('ZIP', size=5),
76- 'phone_prefix': fields.char('Telephone Prefix' , size=16),
77+ 'phone_prefix': fields.char('Telephone Prefix', size=16),
78 'istat_code': fields.char('ISTAT code', size=16),
79 'cadaster_code': fields.char('Cadaster Code', size=16),
80 'web_site': fields.char('Web Site', size=64),
81- 'region': fields.related('province_id','region',type='many2one', relation='res.region', string='Region', readonly=True),
82+ 'region': fields.related(
83+ 'province_id', 'region', type='many2one', relation='res.region',
84+ string='Region', readonly=True),
85 }
86
87+
88 class res_partner(osv.osv):
89 _inherit = 'res.partner'
90
91@@ -67,28 +79,39 @@
92 }
93
94 def on_change_city(self, cr, uid, ids, city):
95- res = {'value':{}}
96+ res = {'value': {}}
97 if(city):
98- city_id = self.pool.get('res.city').search(cr, uid, [('name', '=', city.title())])
99+ city_id = self.pool.get('res.city').search(
100+ cr, uid, [('name', '=ilike', city)])
101 if city_id:
102- city_obj = self.pool.get('res.city').browse(cr, uid, city_id[0])
103+ city_obj = self.pool.get('res.city').browse(
104+ cr, uid, city_id[0])
105 res = {'value': {
106- 'province': city_obj.province_id and city_obj.province_id.id or False,
107+ 'province': (
108+ city_obj.province_id and city_obj.province_id.id
109+ or False
110+ ),
111 'region': city_obj.region and city_obj.region.id or False,
112 'zip': city_obj.zip,
113- 'country_id': city_obj.region and city_obj.region.country_id and city_obj.region.country_id.id or False,
114+ 'country_id': (
115+ city_obj.region and
116+ city_obj.region.country_id and
117+ city_obj.region.country_id.id or False
118+ ),
119 'city': city.title(),
120- }}
121+ }
122+ }
123 return res
124
125 def _set_vals_city_data(self, cr, uid, vals):
126- if vals.has_key('city') and not vals.has_key('province') and not vals.has_key('region'):
127+ if 'city' in vals and 'province' not in vals and 'region' not in vals:
128 if vals['city']:
129- city_obj= self.pool.get('res.city')
130- city_ids = city_obj.search(cr, uid, [('name', '=', vals['city'].title())])
131+ city_obj = self.pool.get('res.city')
132+ city_ids = city_obj.search(
133+ cr, uid, [('name', '=ilike', vals['city'])])
134 if city_ids:
135 city = city_obj.browse(cr, uid, city_ids[0])
136- if not vals.has_key('zip'):
137+ if 'zip' not in vals:
138 vals['zip'] = city.zip
139 if city.province_id:
140 vals['province'] = city.province_id.id
141@@ -105,5 +128,5 @@
142 def write(self, cr, uid, ids, vals, context=None):
143 vals = self._set_vals_city_data(cr, uid, vals)
144 return super(res_partner, self).write(cr, uid, ids, vals, context)
145-
146+
147 res_partner()

Subscribers

People subscribed via source and target branches