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

Subscribers

People subscribed via source and target branches