Merge lp:~rruebner/server-env-tools/7.0_fix_mass_editing into lp:~server-env-tools-core-editors/server-env-tools/7.0

Proposed by Robert Rübner
Status: Work in progress
Proposed branch: lp:~rruebner/server-env-tools/7.0_fix_mass_editing
Merge into: lp:~server-env-tools-core-editors/server-env-tools/7.0
Diff against target: 15 lines (+4/-1)
1 file modified
mass_editing/mass_editing.py (+4/-1)
To merge this branch: bzr merge lp:~rruebner/server-env-tools/7.0_fix_mass_editing
Reviewer Review Type Date Requested Status
Stefan Rijnhart (Opener) Needs Fixing
Joël Grand-Guillaume @ camptocamp code review + tests Approve
Yannick Vaucher @ Camptocamp Needs Information
Review via email: mp+204711@code.launchpad.net

Description of the change

Hi all,

it is possible that the model_id in the for loop is an integer and no string in the overwritten search method in mass_editing.py. We have to ensure that the split call will be done on a string. In addition it is not good to cut the first and the last character of this string, I removed the cutting too.

Without this fix:
e. g. If you edit an email template and select "Search More..." for Field in the Dynamic Value Builder section an error "TypeError: 'int' object has no attribute '_getitem_'" will occur.

Regards
Robert

To post a comment you must log in.
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Hi Robert,

Thanks for the fix. Is there any bug report about this TypeError issue? Can you link it or create it?

This to improve bug traceability.

Regards

review: Needs Information
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

Hi,

I just checked that path and it work perfectly. I had the trouble in editing the email template, when you search for a field and ask for "search more..." you get this crash :

Server Traceback (most recent call last):
  File "/srv/openerp/instances/openerp_test_qoqa/parts/webclient/addons/web/session.py", line 89, in send
    return openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "/srv/openerp/instances/openerp_test_qoqa/parts/server/openerp/netsvc.py", line 292, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/srv/openerp/instances/openerp_test_qoqa/parts/server/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File "/srv/openerp/instances/openerp_test_qoqa/parts/server/openerp/osv/osv.py", line 190, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/srv/openerp/instances/openerp_test_qoqa/parts/server/openerp/osv/osv.py", line 132, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/srv/openerp/instances/openerp_test_qoqa/parts/server/openerp/osv/osv.py", line 199, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/srv/openerp/instances/openerp_test_qoqa/parts/server/openerp/osv/osv.py", line 187, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/srv/openerp/instances/openerp_test_qoqa/parts/server-env-tools/mass_editing/mass_editing.py", line 34, in search
    model_domain += [('model_id', 'in', map(int, domain[2][1:-1].split(',')))]
TypeError: 'int' object has no attribute '__getitem__'

I confirm that this patch fix the issue.

Thanks !

review: Approve (code review + tests)
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Please try removing the whole method/class override of ir_model_fields. The manipulation of the search domain is a leftover from a hack in which the class names were passed on in string format, and they were to be turned into ids in this method. I just tested the module without the search() override and it works fine.

review: Needs Fixing
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Setting to work in progress after five weeks without response.

Unmerged revisions

58. By Robert Rübner

[FIX] Updated search overwriting for ir_model_fields.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'mass_editing/mass_editing.py'
2--- mass_editing/mass_editing.py 2013-05-08 12:41:12 +0000
3+++ mass_editing/mass_editing.py 2014-02-04 15:28:06 +0000
4@@ -31,7 +31,10 @@
5 model_domain = []
6 for domain in args:
7 if domain[0] == 'model_id' and domain[2] and type(domain[2]) != list:
8- model_domain += [('model_id', 'in', map(int, domain[2][1:-1].split(',')))]
9+ # it is possible that the model id is an integer and no string,
10+ # so we have to ensure that the split call will be done with a
11+ # string and without cutting the first and the last character
12+ model_domain += [('model_id', 'in', map(int, str(domain[2]).split(',')))]
13 else:
14 model_domain.append(domain)
15 return super(ir_model_fields, self).search(cr, uid, model_domain, offset=offset, limit=limit, order=order, context=context, count=count)