Merge lp:~fnegrini/openerp.pt-br-localiz/openerp.pt-br-localiz into lp:~openerp-brazil-team/openerp.pt-br-localiz/migr-l10n-br-sale
- openerp.pt-br-localiz
- Merge into migr-l10n-br-sale
Proposed by
Fabio Negrini
Status: | Merged |
---|---|
Merged at revision: | 511 |
Proposed branch: | lp:~fnegrini/openerp.pt-br-localiz/openerp.pt-br-localiz |
Merge into: | lp:~openerp-brazil-team/openerp.pt-br-localiz/migr-l10n-br-sale |
Diff against target: |
643 lines (+352/-151) 6 files modified
l10n_br_data_zip/__openerp__.py (+2/-2) l10n_br_data_zip/l10n_br_data_zip.py (+120/-2) l10n_br_data_zip/l10n_br_data_zip_view.xml (+3/-1) l10n_br_data_zip/res_partner.py (+41/-81) l10n_br_data_zip/wizard/l10n_br_data_zip_search.py (+151/-59) l10n_br_data_zip/wizard/l10n_br_data_zip_search_view.xml (+35/-6) |
To merge this branch: | bzr merge lp:~fnegrini/openerp.pt-br-localiz/openerp.pt-br-localiz |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Renato Lima - http://www.akretion.com | Pending | ||
Review via email: mp+151319@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'l10n_br_data_zip/__openerp__.py' |
2 | --- l10n_br_data_zip/__openerp__.py 2013-02-19 21:03:19 +0000 |
3 | +++ l10n_br_data_zip/__openerp__.py 2013-03-01 21:02:24 +0000 |
4 | @@ -19,7 +19,7 @@ |
5 | |
6 | { |
7 | 'name': 'Brazilian Localisation Data Extension for zip codes', |
8 | - 'description': 'Brazilian Localisation Data Extension for zip codes', |
9 | + 'description': 'Brazilian Localization Data Extension for zip codes', |
10 | 'license': 'AGPL-3', |
11 | 'author': 'Akretion, OpenERP Brasil', |
12 | 'version': '0.1', |
13 | @@ -34,7 +34,7 @@ |
14 | 'security/ir.model.access.csv', |
15 | ], |
16 | 'demo': [], |
17 | - 'category': 'Localisation', |
18 | + 'category': 'Localization', |
19 | 'active': False, |
20 | 'installable': True |
21 | } |
22 | |
23 | === modified file 'l10n_br_data_zip/l10n_br_data_zip.py' |
24 | --- l10n_br_data_zip/l10n_br_data_zip.py 2013-01-19 00:22:49 +0000 |
25 | +++ l10n_br_data_zip/l10n_br_data_zip.py 2013-03-01 21:02:24 +0000 |
26 | @@ -16,7 +16,7 @@ |
27 | #You should have received a copy of the GNU Affero General Public License # |
28 | #along with this program. If not, see <http://www.gnu.org/licenses/>. # |
29 | ############################################################################### |
30 | - |
31 | +import re |
32 | from osv import osv, fields |
33 | |
34 | |
35 | @@ -37,5 +37,123 @@ |
36 | domain="[('country_id','=',country_id)]"), |
37 | 'l10n_br_city_id': fields.many2one( |
38 | 'l10n_br_base.city', 'Cidade', |
39 | - required=True, domain="[('state_id','=',state_id)]") |
40 | + required=True, domain="[('state_id','=',state_id)]"), |
41 | } |
42 | + |
43 | + def set_domain(self, country_id=False, state_id=False, l10n_br_city_id=False, district=False, street=False, zip=False): |
44 | + |
45 | + domain = [] |
46 | + |
47 | + if zip: |
48 | + new_zip = re.sub('[^0-9]', '', zip or '') |
49 | + domain.append(('code', '=', new_zip)) |
50 | + else: |
51 | + |
52 | + if country_id: |
53 | + domain.append(('country_id', '=', country_id)) |
54 | + |
55 | + if state_id: |
56 | + domain.append(('state_id', '=', state_id)) |
57 | + |
58 | + if l10n_br_city_id: |
59 | + domain.append(('l10n_br_city_id', '=', l10n_br_city_id)) |
60 | + |
61 | + if district: |
62 | + domain.append(('district', 'like', district)) |
63 | + |
64 | + if street: |
65 | + domain.append(('street', 'like', street)) |
66 | + |
67 | + return domain |
68 | + |
69 | + def set_result(self, cr, uid, ids, context, zip_id=None): |
70 | + |
71 | + result = { |
72 | + 'country_id': False, |
73 | + 'state_id': False, |
74 | + 'l10n_br_city_id': False, |
75 | + 'district': False, |
76 | + 'street': False, |
77 | + 'zip': False |
78 | + } |
79 | + |
80 | + if zip_id != None: |
81 | + |
82 | + zip_read = self.read(cr, uid, zip_id, [ |
83 | + 'street_type', |
84 | + 'street', |
85 | + 'district', |
86 | + 'code', |
87 | + 'l10n_br_city_id', |
88 | + 'state_id', |
89 | + 'country_id' |
90 | + ], |
91 | + context=context)[0] |
92 | + |
93 | + zip = zip_read['code'] |
94 | + |
95 | + if len(zip) == 8: |
96 | + zip = '%s-%s' % (zip[0:5], zip[5:8]) |
97 | + |
98 | + result = { |
99 | + 'country_id': zip_read['country_id'] and zip_read['country_id'][0] or False, |
100 | + 'state_id': zip_read['state_id'] and zip_read['state_id'][0] or False, |
101 | + 'l10n_br_city_id': zip_read['l10n_br_city_id'] and zip_read['l10n_br_city_id'][0] or False, |
102 | + 'district': (zip_read['district'] or ''), |
103 | + 'street': ((zip_read['street_type'] or '') + ' ' + (zip_read['street'] or '')), |
104 | + 'zip': zip, |
105 | + } |
106 | + |
107 | + return result |
108 | + |
109 | + |
110 | + def zip_search(self, cr, uid, ids, context, country_id=False, state_id=False, l10n_br_city_id=False, district=False, street=False, zip=False): |
111 | + |
112 | + result = self.set_result(cr, uid, ids, context) |
113 | + |
114 | + domain = self.set_domain(country_id = country_id, |
115 | + state_id = state_id, |
116 | + l10n_br_city_id = l10n_br_city_id, |
117 | + district = district, |
118 | + street = street, |
119 | + zip = zip) |
120 | + |
121 | + zip_id = self.search(cr, uid, domain) |
122 | + |
123 | + if len(zip_id) == 1: |
124 | + |
125 | + result = self.set_result(cr, uid, ids, context, zip_id) |
126 | + |
127 | + return result |
128 | + |
129 | + else: |
130 | + |
131 | + return False |
132 | + |
133 | + def create_wizard(self, cr, uid, ids, context, object_name, country_id=False, state_id=False, l10n_br_city_id=False, district=False, street=False, zip=False): |
134 | + |
135 | + context.update({'zip': zip, |
136 | + 'street': street, |
137 | + 'district': district, |
138 | + 'country_id': country_id, |
139 | + 'state_id': state_id, |
140 | + 'l10n_br_city_id': l10n_br_city_id, |
141 | + 'address_id': ids[0], |
142 | + 'object_name': object_name}) |
143 | + |
144 | + result = { |
145 | + 'name': 'Zip Search', |
146 | + 'view_type': 'form', |
147 | + 'view_mode': 'form', |
148 | + 'res_model': 'l10n_br_data.zip.search', |
149 | + 'view_id': False, |
150 | + 'context': context, |
151 | + 'type': 'ir.actions.act_window', |
152 | + 'target': 'new', |
153 | + 'nodestroy': True, |
154 | + } |
155 | + |
156 | + return result |
157 | + |
158 | +l10n_br_data_zip() |
159 | + |
160 | |
161 | === modified file 'l10n_br_data_zip/l10n_br_data_zip_view.xml' |
162 | --- l10n_br_data_zip/l10n_br_data_zip_view.xml 2012-12-11 04:31:17 +0000 |
163 | +++ l10n_br_data_zip/l10n_br_data_zip_view.xml 2013-03-01 21:02:24 +0000 |
164 | @@ -8,6 +8,7 @@ |
165 | <field name="arch" type="xml"> |
166 | <tree string="CEPs"> |
167 | <field name="code" select="1"/> |
168 | + <field name="district" select="1"/> |
169 | <field name="street_type" select="1"/> |
170 | <field name="street" select="1"/> |
171 | </tree> |
172 | @@ -29,7 +30,8 @@ |
173 | </form> |
174 | </field> |
175 | </record> |
176 | - |
177 | + |
178 | + |
179 | <record model="ir.actions.act_window" id="action_l10n_br_data_zip"> |
180 | <field name="name">CEPs</field> |
181 | <field name="type">ir.actions.act_window</field> |
182 | |
183 | === modified file 'l10n_br_data_zip/res_partner.py' |
184 | --- l10n_br_data_zip/res_partner.py 2013-01-20 23:42:40 +0000 |
185 | +++ l10n_br_data_zip/res_partner.py 2013-03-01 21:02:24 +0000 |
186 | @@ -27,88 +27,48 @@ |
187 | #TODO migrate |
188 | def zip_search(self, cr, uid, ids, context=None): |
189 | |
190 | - result = { |
191 | - 'street': False, |
192 | - 'l10n_br_city_id': False, |
193 | - 'city': False, |
194 | - 'state_id': False, |
195 | - 'country_id': False, |
196 | - 'zip': False |
197 | - } |
198 | - |
199 | obj_zip = self.pool.get('l10n_br_data.zip') |
200 | |
201 | for res_partner in self.browse(cr, uid, ids): |
202 | - |
203 | - domain = [] |
204 | - if res_partner.zip: |
205 | - zip = re.sub('[^0-9]', '', res_partner.zip or '') |
206 | - domain.append(('code', '=', zip)) |
207 | + |
208 | + zip_read = obj_zip.zip_search(cr, uid, ids, context, |
209 | + country_id = res_partner.country_id.id, \ |
210 | + state_id = res_partner.state_id.id, \ |
211 | + l10n_br_city_id = res_partner.l10n_br_city_id.id, \ |
212 | + district = res_partner.district, \ |
213 | + street = res_partner.street, \ |
214 | + zip = res_partner.zip, |
215 | + ) |
216 | + |
217 | + if zip_read != False: |
218 | + |
219 | + result = { |
220 | + 'country_id': zip_read['country_id'], |
221 | + 'state_id': zip_read['state_id'], |
222 | + 'l10n_br_city_id': zip_read['l10n_br_city_id'], |
223 | + 'district': zip_read['district'], |
224 | + 'street': zip_read['street'], |
225 | + 'zip': zip_read['zip'], |
226 | + } |
227 | + |
228 | + self.write(cr, uid, res_partner.id, result) |
229 | + |
230 | + return False |
231 | + |
232 | else: |
233 | - domain.append(('street', '=', res_partner.street)) |
234 | - domain.append(('district', '=', res_partner.district)) |
235 | - domain.append(('country_id', '=', \ |
236 | - res_partner.country_id.id)) |
237 | - domain.append(('state_id', '=', \ |
238 | - res_partner.state_id.id)) |
239 | - domain.append(('l10n_br_city_id', '=', \ |
240 | - res_partner.l10n_br_city_id.id)) |
241 | - |
242 | - zip_id = obj_zip.search(cr, uid, domain) |
243 | - |
244 | - if not len(zip_id) == 1: |
245 | - |
246 | - context.update({ |
247 | - 'zip': res_partner.zip, |
248 | - 'street': res_partner.street, |
249 | - 'district': res_partner.district, |
250 | - 'country_id': \ |
251 | - res_partner.country_id.id, |
252 | - 'state_id': res_partner.state_id.id, |
253 | - 'l10n_br_city_id': \ |
254 | - res_partner.l10n_br_city_id.id, |
255 | - 'address_id': ids, |
256 | - 'object_name': self._name, |
257 | - }) |
258 | - |
259 | - result = { |
260 | - 'name': 'Zip Search', |
261 | - 'view_type': 'form', |
262 | - 'view_mode': 'form', |
263 | - 'res_model': 'l10n_br_data.zip.search', |
264 | - 'view_id': False, |
265 | - 'context': context, |
266 | - 'type': 'ir.actions.act_window', |
267 | - 'target': 'new', |
268 | - 'nodestroy': True, |
269 | - } |
270 | - return result |
271 | - |
272 | - zip_read = obj_zip.read(cr, uid, zip_id, [ |
273 | - 'street_type', |
274 | - 'street', 'district', |
275 | - 'code', |
276 | - 'l10n_br_city_id', |
277 | - 'city', 'state_id', |
278 | - 'country_id' |
279 | - ], |
280 | - context=context)[0] |
281 | - |
282 | - zip = re.sub('[^0-9]', '', zip_read['code'] or '') |
283 | - if len(zip) == 8: |
284 | - zip = '%s-%s' % (zip[0:5], zip[5:8]) |
285 | - |
286 | - result['street'] = ((zip_read['street_type'] or '') + ' ' \ |
287 | - + (zip_read['street'] or '')) |
288 | - result['district'] = zip_read['district'] |
289 | - result['zip'] = zip |
290 | - result['l10n_br_city_id'] = zip_read['l10n_br_city_id'] \ |
291 | - and zip_read['l10n_br_city_id'][0] or False |
292 | - result['city'] = zip_read['l10n_br_city_id'] \ |
293 | - and zip_read['l10n_br_city_id'][1] or '' |
294 | - result['state_id'] = zip_read['state_id'] \ |
295 | - and zip_read['state_id'][0] or False |
296 | - result['country_id'] = zip_read['country_id'] \ |
297 | - and zip_read['country_id'][0] or False |
298 | - self.write(cr, uid, res_partner.id, result) |
299 | - return False |
300 | + |
301 | + return obj_zip.create_wizard(cr, uid, ids, context, self._name, |
302 | + country_id = res_partner.country_id.id, \ |
303 | + state_id = res_partner.state_id.id, \ |
304 | + l10n_br_city_id = res_partner.l10n_br_city_id.id, \ |
305 | + district = res_partner.district, \ |
306 | + street = res_partner.street, \ |
307 | + zip = res_partner.zip, |
308 | + ) |
309 | + |
310 | + |
311 | + |
312 | + |
313 | + |
314 | + |
315 | + |
316 | |
317 | === modified file 'l10n_br_data_zip/wizard/l10n_br_data_zip_search.py' |
318 | --- l10n_br_data_zip/wizard/l10n_br_data_zip_search.py 2013-01-03 04:21:33 +0000 |
319 | +++ l10n_br_data_zip/wizard/l10n_br_data_zip_search.py 2013-03-01 21:02:24 +0000 |
320 | @@ -23,6 +23,7 @@ |
321 | from osv import osv, fields |
322 | |
323 | |
324 | + |
325 | class l10n_br_data_zip_search(osv.osv_memory): |
326 | _name = 'l10n_br_data.zip.search' |
327 | _description = 'Zipcode Search' |
328 | @@ -38,11 +39,16 @@ |
329 | 'l10n_br_city_id': fields.many2one( |
330 | 'l10n_br_base.city', 'Cidade', |
331 | domain="[('state_id','=',state_id)]"), |
332 | - 'zip_ids': fields.many2many('l10n_br_data.zip','zip_search', |
333 | + |
334 | + 'zip_ids': fields.many2many('l10n_br_data.zip.result','zip_search', |
335 | 'zip_id', 'zip_search_id', 'CEP', |
336 | - readonly=True), |
337 | + readonly=False), |
338 | + |
339 | 'state':fields.selection([('init','init'), |
340 | - ('done','done')], 'state', readonly=True)} |
341 | + ('done','done')], 'state', readonly=True), |
342 | + 'address_id': fields.integer('Id do objeto', invisible=True), |
343 | + 'object_name': fields.char('Nome do bjeto', size=100, invisible=True), |
344 | + } |
345 | |
346 | _defaults = { |
347 | 'state': 'init'} |
348 | @@ -61,38 +67,132 @@ |
349 | data['country_id'] = context.get('country_id', False) |
350 | data['state_id'] = context.get('state_id', False) |
351 | data['l10n_br_city_id'] = context.get('l10n_br_city_id', False) |
352 | - |
353 | + data['address_id'] = context.get('address_id', False) |
354 | + data['object_name'] = context.get('object_name', False) |
355 | return data |
356 | + |
357 | + |
358 | + |
359 | |
360 | def zip_search(self, cr, uid, ids, context=None): |
361 | |
362 | data = self.read(cr, uid, ids, [], context=context)[0] |
363 | |
364 | - domain = [ |
365 | - ('country_id','=',data['country_id'][0]), |
366 | - ('state_id','=',data['state_id'][0]), |
367 | - ('l10n_br_city_id','=',data['l10n_br_city_id'][0]),] |
368 | - |
369 | - if data['code']: |
370 | - zip = re.sub('[^0-9]', '', data['code'] or '') |
371 | - domain.append(('code','=',zip)) |
372 | - |
373 | - if data['street']: |
374 | - domain.append(('street','=',data['street'])) |
375 | - |
376 | - if data['district']: |
377 | - domain.append(('district','=',data['district'])) |
378 | - |
379 | obj_zip = self.pool.get('l10n_br_data.zip') |
380 | + |
381 | + obj_zip_result = self.pool.get('l10n_br_data.zip.result') |
382 | + |
383 | + domain = obj_zip.set_domain(country_id = data['country_id'][0], \ |
384 | + state_id = data['state_id'][0], \ |
385 | + l10n_br_city_id = data['l10n_br_city_id'][0],\ |
386 | + district = data['district'], \ |
387 | + street = data['street'], \ |
388 | + zip = data['code']) |
389 | + |
390 | + |
391 | + # Search zip_ids |
392 | zip_ids = obj_zip.search(cr, uid, domain) |
393 | |
394 | + #TODO: MAP zip to zip.search.result |
395 | + zip_result_ids = obj_zip_result.map_to_zip_result(cr, uid, ids, context, data['id'], zip_ids) |
396 | + |
397 | self.write(cr, uid, ids, |
398 | {'state': 'done', |
399 | - 'zip_ids': [[6, 0, zip_ids]]}, context=context) |
400 | - return False |
401 | - |
402 | - def zip_search_end(self, cr, uid, ids, context=None): |
403 | - |
404 | + 'zip_ids': [[6, 0, zip_result_ids]]}, context=context) |
405 | + |
406 | + return { |
407 | + 'type': 'ir.actions.act_window', |
408 | + 'res_model': 'l10n_br_data.zip.search', |
409 | + 'view_mode': 'form', |
410 | + 'view_type': 'form', |
411 | + 'res_id': data['id'], |
412 | + 'views': [(False, 'form')], |
413 | + 'target': 'new', |
414 | + } |
415 | + |
416 | + def zip_new_search(self, cr, uid, ids, context=None): |
417 | + |
418 | + data = self.read(cr, uid, ids, [], context=context)[0] |
419 | + |
420 | + self.write(cr, uid, ids, |
421 | + {'state': 'init', |
422 | + 'zip_ids': [[6, 0, []]]}, context=context) |
423 | + |
424 | + return { |
425 | + 'type': 'ir.actions.act_window', |
426 | + 'res_model': 'l10n_br_data.zip.search', |
427 | + 'view_mode': 'form', |
428 | + 'view_type': 'form', |
429 | + 'res_id': data['id'], |
430 | + 'views': [(False, 'form')], |
431 | + 'target': 'new', |
432 | + } |
433 | + |
434 | +l10n_br_data_zip_search() |
435 | + |
436 | +class l10n_br_data_zip_result(osv.osv_memory): |
437 | + _name = 'l10n_br_data.zip.result' |
438 | + _description = 'Zipcode result' |
439 | + |
440 | + _columns = { |
441 | + 'zip_id': fields.many2one('l10n_br_data.zip', 'Zipcode', readonly=True, invisible=True), |
442 | + 'search_id': fields.many2one('l10n_br_data.zip.search', 'Search', readonly=True, invisible=True), |
443 | + #ZIPCODE data to be shown |
444 | + 'code': fields.char('CEP', size=8, readonly=True), |
445 | + 'street': fields.char('Logradouro', size=72, readonly=True), |
446 | + 'district': fields.char('Bairro', size=72, readonly=True), |
447 | + 'country_id': fields.many2one('res.country', 'Country', readonly=True), |
448 | + 'state_id': fields.many2one('res.country.state', 'Estado', |
449 | + domain="[('country_id','=',country_id)]", readonly=True), |
450 | + 'l10n_br_city_id': fields.many2one( |
451 | + 'l10n_br_base.city', 'Cidade', |
452 | + required=True, domain="[('state_id','=',state_id)]", readonly=True), |
453 | + } |
454 | + |
455 | + |
456 | + def map_to_zip_result(self, cr, uid, ids, context, search_id, zip_ids): |
457 | + |
458 | + obj_zip = self.pool.get('l10n_br_data.zip') |
459 | + |
460 | + result = [] |
461 | + |
462 | + for zip_id in zip_ids: |
463 | + |
464 | + zip_data = obj_zip.set_result(cr, uid, ids, context, [zip_id]) |
465 | + |
466 | + zip_result_data = { |
467 | + 'selected': False, |
468 | + 'zip_id': False, |
469 | + 'code': False, |
470 | + 'street': False, |
471 | + 'district': False, |
472 | + 'country_id': False, |
473 | + 'state_id': False, |
474 | + 'l10n_br_city_id': False, |
475 | + } |
476 | + |
477 | + zip_result_data['zip_id'] = zip_id |
478 | + zip_result_data['search_id'] = search_id |
479 | + zip_result_data['code'] = zip_data['zip'] |
480 | + zip_result_data['street'] = zip_data['street'] |
481 | + zip_result_data['district'] = zip_data['district'] |
482 | + zip_result_data['country_id'] = zip_data['country_id'] |
483 | + zip_result_data['state_id'] = zip_data['state_id'] |
484 | + zip_result_data['l10n_br_city_id'] = zip_data['l10n_br_city_id'] |
485 | + |
486 | + |
487 | + zip_result_id = self.create(cr, uid, zip_result_data, context=context) |
488 | + |
489 | + result.append(zip_result_id) |
490 | + |
491 | + return result |
492 | + |
493 | + def zip_select(self, cr, uid, ids, context=None): |
494 | + |
495 | + data = self.read(cr, uid, ids, [], context=context)[0] |
496 | + |
497 | + obj_search = self.pool.get('l10n_br_data.zip.search') |
498 | + |
499 | result = { |
500 | 'street': False, |
501 | 'l10n_br_city_id': False, |
502 | @@ -101,38 +201,30 @@ |
503 | 'country_id': False, |
504 | 'zip': False |
505 | } |
506 | - |
507 | - data = self.read(cr, uid, ids, [], context=context)[0] |
508 | - |
509 | - if data['zip_ids']: |
510 | - address_id = context.get('address_id', False) |
511 | - object_name = context.get('object_name', False) |
512 | - if address_id and object_name: |
513 | - obj_zip = self.pool.get('l10n_br_data.zip') |
514 | - zip_read = obj_zip.read( |
515 | - cr, uid, data['zip_ids'], ['street_type', |
516 | - 'street', |
517 | - 'district', |
518 | - 'code', |
519 | - 'l10n_br_city_id', |
520 | - 'city', 'state_id', |
521 | - 'country_id'], context=context)[0] |
522 | - |
523 | - zip = re.sub('[^0-9]', '', zip_read['code'] or '') |
524 | - if len(zip) == 8: |
525 | - zip = '%s-%s' % (zip[0:5], zip[5:8]) |
526 | - |
527 | - result['street'] = ((zip_read['street_type'] or '') + ' ' + (zip_read['street'] or '')) |
528 | - result['district'] = zip_read['district'] |
529 | - result['zip'] = zip |
530 | - result['l10n_br_city_id'] = zip_read['l10n_br_city_id'] and zip_read['l10n_br_city_id'][0] or False |
531 | - result['city'] = zip_read['l10n_br_city_id'] and zip_read['l10n_br_city_id'][1] or '' |
532 | - result['state_id'] = zip_read['state_id'] and zip_read['state_id'][0] or False |
533 | - result['country_id'] = zip_read['country_id'] and zip_read['country_id'][0] or False |
534 | - |
535 | - obj_partner = self.pool.get(object_name) |
536 | - obj_partner.write(cr, uid, address_id, result, context=context) |
537 | - |
538 | - return {'type': 'ir.actions.act_window_close'} |
539 | - |
540 | -l10n_br_data_zip_search() |
541 | + |
542 | + search_values = obj_search.read(cr, uid,[data['search_id'][0]], |
543 | + ['address_id', |
544 | + 'object_name'], |
545 | + context=context)[0] |
546 | + |
547 | + address_id = search_values['address_id'] |
548 | + |
549 | + object_name = search_values['object_name'] |
550 | + |
551 | + obj_zip = self.pool.get('l10n_br_data.zip') |
552 | + |
553 | + result = obj_zip.set_result(cr, uid, ids, context, [data['zip_id'][0]]) |
554 | + |
555 | + if address_id and object_name: |
556 | + |
557 | + obj = self.pool.get(object_name) |
558 | + |
559 | + obj.write(cr, uid, address_id, result, context=context) |
560 | + |
561 | + |
562 | + return { |
563 | + 'type': 'ir.actions.act_window_close', |
564 | + 'value': result, |
565 | + } |
566 | + |
567 | +l10n_br_data_zip_result() |
568 | |
569 | === modified file 'l10n_br_data_zip/wizard/l10n_br_data_zip_search_view.xml' |
570 | --- l10n_br_data_zip/wizard/l10n_br_data_zip_search_view.xml 2013-01-03 04:21:33 +0000 |
571 | +++ l10n_br_data_zip/wizard/l10n_br_data_zip_search_view.xml 2013-03-01 21:02:24 +0000 |
572 | @@ -1,7 +1,7 @@ |
573 | <?xml version="1.0" encoding="utf-8"?> |
574 | <openerp> |
575 | <data noupdate="0"> |
576 | - |
577 | + |
578 | <record id="view_l10n_br_data_zip_search" model="ir.ui.view"> |
579 | <field name="name">Pesquisar CEP</field> |
580 | <field name="model">l10n_br_data.zip.search</field> |
581 | @@ -19,20 +19,49 @@ |
582 | </group> |
583 | <group colspan="8" col="8" states="done"> |
584 | <!-- <separator colspan="8" string="Resuldado da Pesquisa"/> --> |
585 | - <field colspan="8" height="130" nolabel="1" name="zip_ids" /> |
586 | + <field colspan="8" height="130" nolabel="1" name="zip_ids" wizard="one2many_list" readonly="1"/> |
587 | </group> |
588 | <footer states="init"> |
589 | <button name="zip_search" string="Pesquisar" type="object" class="oe_highlight"/> |
590 | - or |
591 | <button special="cancel" string="Cancelar" class="oe_link"/> |
592 | </footer> |
593 | <footer states="done"> |
594 | - <button name="zip_search_end" type="object" string="Fechar" class="oe_highlight"/> |
595 | + <button name="zip_new_search" string="Nova Pesquisa" type="object" class="oe_highlight"/> |
596 | + <button special="cancel" string="Cancelar" class="oe_link"/> |
597 | </footer> |
598 | </form> |
599 | </field> |
600 | </record> |
601 | - |
602 | + |
603 | + <record model="ir.ui.view" id="view_l10n_br_data_zip_result_tree"> |
604 | + <field name="name">l10n_br_data.zip.result</field> |
605 | + <field name="model">l10n_br_data.zip.result</field> |
606 | + <field name="arch" type="xml"> |
607 | + <tree string="CEPs"> |
608 | + <!-- <field name="selected" colspan="2" select="1"/> --> |
609 | + <button name="zip_select" string="Selecionar" type="object" icon="gtk-apply"/> |
610 | + <field name="code" select="1"/> |
611 | + <field name="district" select="1"/> |
612 | + <field name="street" select="1"/> |
613 | + </tree> |
614 | + </field> |
615 | + </record> |
616 | + |
617 | + <record model="ir.ui.view" id="view_l10n_br_data_zip_result_form"> |
618 | + <field name="name">l10n_br_data.zip.result</field> |
619 | + <field name="model">l10n_br_data.zip.result</field> |
620 | + <field name="arch" type="xml"> |
621 | + <form string="CEPs"> |
622 | + <field name="code" select="1"/> |
623 | + <field name="street" select="1"/> |
624 | + <field name="district" select="2"/> |
625 | + <field name="country_id" select="2"/> |
626 | + <field name="state_id" select="2"/> |
627 | + <field name="l10n_br_city_id" select="2"/> |
628 | + </form> |
629 | + </field> |
630 | + </record> |
631 | + |
632 | <record id="action_l10n_br_data_zip_search" model="ir.actions.act_window"> |
633 | <field name="name">Pesquisar CEP</field> |
634 | <field name="type">ir.actions.act_window</field> |
635 | @@ -41,6 +70,6 @@ |
636 | <field name="view_mode">form</field> |
637 | <field name="target">new</field> |
638 | </record> |
639 | - |
640 | + |
641 | </data> |
642 | </openerp> |
643 | \ No newline at end of file |
valeu pela força Fabio, vamos analisar isso o mais cedo possivel!