← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 753286] Re: [5.0] Copy of ir_attachment

 

Hello Ignacio,

Whenever you are dealing with the ids in a methods like create, write then you can use the
                       if isinstance(ids, (int, long)):
                                  ids = [ids]
But in copy method we are only passing the id so no need to check it in list. If you do so you will get the following traceback:

Traceback (most recent call last):
  File "/home/tiny/workspace/trunk/openobject-server/openerp/osv/osv.py", line 122, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/tiny/workspace/trunk/openobject-server/openerp/osv/osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/tiny/workspace/trunk/openobject-server/openerp/osv/osv.py", line 167, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/tiny/workspace/trunk/openobject-addons/document/document.py", line 205, in copy
    name = self.read(cr, uid, [id], ['name'])[0]['name']
  File "/home/tiny/workspace/trunk/openobject-server/openerp/addons/base/ir/ir_attachment.py", line 102, in read
    return super(ir_attachment, self).read(cr, uid, ids, fields_to_read, context, load)
  File "/home/tiny/workspace/trunk/openobject-server/openerp/osv/orm.py", line 2937, in read
    result = self._read_flat(cr, user, select, fields, context, load)
  File "/home/tiny/workspace/trunk/openobject-server/openerp/osv/orm.py", line 2988, in _read_flat
    for sub_ids in cr.split_for_in_conditions(ids):
  File "/home/tiny/workspace/trunk/openobject-server/openerp/sql_db.py", line 163, in split_for_in_conditions
    return tools.misc.split_every(self.IN_MAX, set(ids))
TypeError: unhashable type: 'list'


So it is better to remove such piece of code. Hope this will clear the point. I am closing this issue as it is not the bug and in this case you need not to change the code of base.

Thanks.


** Changed in: openobject-server
       Status: Incomplete => Invalid

-- 
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/753286

Title:
  [5.0] Copy of ir_attachment

Status in OpenERP Server:
  Invalid

Bug description:
  An error is thrown when duplicating an attachment using
  self.pool.get('ir.attachment').copy( ... )

  Reason being the list of ids passed to the method gets "over
  bracketed" and therefore the select query throws an exception

  I attach some logs I added to the code for debuggin purposes

  First I list some logs I get when calling to self.pool.get('ir.attachment').search (this method works fine)
   [2011-04-07 10:12:57,002] ESC[32mESC[49mINFOESC[0m:ir_attachment.read:[3, 7]
   [2011-04-07 10:12:57,003] ESC[32mESC[49mINFOESC[0m:ir_attachment.check:begin
   [2011-04-07 10:12:57,003] ESC[32mESC[49mINFOESC[0m:ir_attachment.check:3,7
   [2011-04-07 10:12:57,004] ESC[32mESC[49mINFOESC[0m:ir_attachment.check:end

  Now the logs I get when making a call to the copy method (exception thrown)
   [2011-04-07 10:12:57,006] ESC[32mESC[49mINFOESC[0m:ir_attachment.read:[[3, 7]]
   [2011-04-07 10:12:57,006] ESC[32mESC[49mINFOESC[0m:ir_attachment.check:begin
   [2011-04-07 10:12:57,006] ESC[32mESC[49mINFOESC[0m:ir_attachment.check:[3, 7]
   ...
   [2011-04-07 10:12:57,308] ESC[31mESC[49mERRORESC[0m:web-services:[74]: PrNEA 1: ...t distinct res_model from ir_attachment where id in ([3, 7])

  I'm using openERP 5.0.10 on Ubuntu

  Kind Regards



References