[5.0] Incorrect reuse of same m2m table by 2 osv objects in document module prevents creating more than a few files

Bug #666247 reported by nima
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Medium
Jay Vora (Serpent Consulting Services)

Bug Description

hi,
this is the full cause of problem.i go to the document management module::search a file::New.
in the new section when i choose a file and attach it without any further changes it operates fine .but when i go to security tab and add some groups i get the following integrity error:

Integrity Error

insert or update on table "document_directory_group_rel" violates foreign key constraint "document_directory_group_rel_item_id_fkey"
DETAIL: Key (item_id)=(228) is not present in table "document_directory".

what is it??

thank you

Tags: maintenance

Related branches

Revision history for this message
xrg (xrg) wrote : Re: [Bug 666247] [NEW] Problem when uploading a file via ftp in document management module

On Monday 25 October 2010, you wrote:
> Public bug reported:
>
> hi,
> this is the full cause of problem.i go to the document management
> module::search a file::New. in the new section when i choose a file and
> attach it without any further changes it operates fine .but when i go to
> security tab and add some groups i get the following integrity error:
>

What version of OpenERP are you using?

Did you refresh the list on the OpenERP client interface, after operating
through FTP? You know, FTP is a parallel client, so its opeations need to be
synchronised..

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote : Re: Problem when uploading a file via ftp in document management module

re-filing under addons, document_ftp is a separate module, not part of the core

affects: openobject-server → openobject-addons
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Hello,
We can't reproduce on latest trunk, and the scenario you are describing does not seem to indicate that you are using the latest version.
Could you try again with the latest 6.0 version (RC1)?

If you manage to reproduce, please mention the exact version and steps to reproduce it (for example it's not clear in your description when you actually used the FTP protocol, or if you only used an OpenERP client)

Thank you!

Changed in openobject-addons:
status: New → Incomplete
Revision history for this message
nima (0.5a) wrote :

i am using openerp 5.0.14 .under client software i use Document Management.and when i go to search a file in that module i press from above the form New.in this section i browse my file and in permission section i choose the groups that i want to give access to connect to this file .if i press save it will bring on the error.but when i don't specify permissions it will save ok.it happens if i even change the existing file permission list.
thank you

Revision history for this message
nima (0.5a) wrote :

anybody have any idea about this problem?does it occur to u too?

Changed in openobject-addons:
status: Incomplete → New
status: New → Opinion
Revision history for this message
nima (0.5a) wrote :

ok,i deleted "document_directory_group_rel_item_id_fkey" manually in my database and everything is ok now.i certainly believe this is not a bug but a misuse of the database.so does anyone have any idea what that constraint was doing and why every thing is OK in a fresh database and not mine?

Changed in openobject-addons:
status: Opinion → Invalid
Revision history for this message
LudoRA (tenshi20) wrote :

Hi!

This bug affect me too. It's exactly the same way to reproduce it.

I'm using 5.0.15 version. It was working for few day, and now, it isn't.

Changed in openobject-addons:
status: Invalid → Confirmed
Revision history for this message
LudoRA (tenshi20) wrote :

After code analyse, I can reproduce this bug with a 5.0.15 fresh install.

This portion of error message DETAIL: Key (item_id)=(228) is not present in table "document_directory" give us the information that 228 is not prensent in document_directory table. It's logic because this table list directories, not documents (that are in ir.attachment table).

So, when we increase the id of our documents, when we are over the most id of directory, the database refuse to be updated because of id of the document isn't in the list of directory.

It could have an ir_attachment_group_rel table to reference security rules for each document .

Revision history for this message
LudoRA (tenshi20) wrote :

Change the 586'th line :

        'group_ids': fields.many2many('res.groups', 'document_directory_group_rel', 'item_id', 'group_id', 'Groups'),
to
        'group_ids': fields.many2many('res.groups', 'ir_attachment_group_rel', 'item_id', 'group_id', 'Groups'),

It seems to work with a fresh install.
For an already exist install, I suppose that you have to reaffect group for each document you have already put on the server.

Do you think it's a good way to sove the problem?

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

@LudoRA: your analysis is totally correct, the name of the many-to-many relationship table of the document.directory class was reused incorrectly in the document_directory class!
Thanks to you and Nima for reporting and analyzing this issue.

I can confirm that 6.0 is unaffected, so this is only in the 5.0 series.

As a result, I am assigning to the maintenance team, so they can apply the fix.

Changed in openobject-addons:
assignee: nobody → Jay Vora (OpenERP) (jvo-openerp)
importance: Undecided → Medium
milestone: none → 5.0.16
summary: - Problem when uploading a file via ftp in document management module
+ [5.0] Incorrect reuse of same m2m table by 2 osv objects in document
+ module prevents creating more than a few files
tags: added: maintenance
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

@LudoRA: your patch would work, and here is a similar one in patch format, that should be readily applicable to any 5.0 installation. Note that you need to manually trigger an update of the document module after applying the patch.

Revision history for this message
LudoRA (tenshi20) wrote :

@Olivier Dony: OK. Can we consider this patch like an official patch that is compatible with futures versions of 5.0 series? Or must we wait for a validation?

Changed in openobject-addons:
status: Confirmed → In Progress
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Thanks everyone for the participation.
It has been fixed in 5.0 by revision 2899 <email address hidden>.

Changed in openobject-addons:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.