openerp-india team mailing list archive
-
openerp-india team
-
Mailing list archive
-
Message #13657
[Bug 1024958] Re: count attachment crashes or gives wrong value. Error in _search function
*** This bug is a duplicate of bug 962229 ***
https://bugs.launchpad.net/bugs/962229
** This bug has been marked a duplicate of bug 962229
[6.1][ir_attachement] _search method should work with count option
--
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Server.
https://bugs.launchpad.net/bugs/1024958
Title:
count attachment crashes or gives wrong value. Error in _search
function
Status in OpenERP Server:
New
Bug description:
I will try to be as clear as possible :-)
I am using openerp 6.1
if the function _search in ir_attachment.py is called with the
parameter count=True (eg for having the number of attachments shown on
the button attachments in the client) The function can generate an
error or give an invalid count.
the problem is in line 58.
def _search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False, access_rights_uid=None):
ids = super(ir_attachment, self)._search(cr, uid, args, offset=offset,
limit=limit, order=order,
context=context, count=count,
access_rights_uid=access_rights_uid)
this should be:
ids = super(ir_attachment, self)._search(cr, uid, args, offset=offset,
limit=limit, order=order,
+ context=context, count=False,
- context=context, count=count,
access_rights_uid=access_rights_uid)
-> you want to get a list of the existing attachements and later on
you count the ones where you have permission to. If count=count(=True)
then you get the number of attachments, if this number by accident is
the same as an existing id then you can get a wrong value. If the
number isn't by accident an existing id then the system crashes later
in the code.
The error can be reproduced in the gtk-client by:
- create an empty database
- create an attachment somewhere (id=1)
- delete this attachment (=> id=1 is removed)
- create a new attachment on a certain object eg sale order (id=2)
now if you open the sale order where the attachment is attached to the system crashes when trying to get the number of attachments attached to this sales order (for showing on the attachment button)
what happens:
in the line ids = super(ir_attachement,...... the amount of attachements is fetched from the database, in this case = 1. Then this is used as an id of an attachement, but this doesn't exists :-) =>error when trying to loop through the attachements.
To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/1024958/+subscriptions
References