[trunk][account][low] Inversion of two columns in a many2many field

Bug #705797 reported by Olivier DOSSMANN
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Low
OpenERP R&D Addons Team 3

Bug Description

Addons: revno. 4372

By browsing the table account_bank_statement_line_move_rel in a database created with the trunk, I see that this table have two columns :
- move_id
- statement_id

The first should refers to account_move, the second to account_bank_statement.

By using openerp, I have some values inserted into the database. It seems that move_id contains values that should be in statement_id and inversely.

In fact it's easy to change this. You just have to go to account/account_bank_statement.py#465-467 and change lines :

'move_ids': fields.many2many('account.move',
    'account_bank_statement_line_move_rel', 'move_id','statement_id',
    'Moves'),

by :

'move_ids': fields.many2many('account.move',
    'account_bank_statement_line_move_rel', 'statement_id','move_id',
    'Moves'),

It's not so important because of ORM methods use (like browse, etc.). But imagine someone develop a module which use a sql query like in account/account_move_line.py#786-790 but on account_bank_statement_line_move_rel ... that will affect the developer's result.

Thanks for advance about this non-critical bug but important for those who parses the database and develops modules ;)

Related branches

Revision history for this message
Olivier DOSSMANN (odossmann) wrote :

Note that this should appears frequently if the documentation give 2 versions of "how make a many2many". Have a look : http://doc.openerp.com/developer/2_5_Objects_Fields_Methods/field_type.html#relational-types

First we read this :

fields.many2many('other.object.name',
                 'relation object',
                 'actual.object.id',
                 'other.object.id',
                 'Field Name')

Then we read this :

class other_object_name2(osv.osv):
    _inherit = 'other.object.name'
    _columns = {
        'other_fields': fields.many2many(
            'actual.object.name',
            'relation object',
            'actual.object.id',
            'other.object.id',
            'Other Field Name'),
    }
other_object_name2()

The other.object.id is at the fourth place, then @t third place.

Revision history for this message
DBR (OpenERP) (dbr-openerp) wrote :

Hello Olivier DOSSMANN,

Thanks for reporting.
This problem will be solved in new documentation.

Thanks.

Changed in openobject-addons:
status: New → Invalid
Revision history for this message
Olivier DOSSMANN (odossmann) wrote :

Thanks for resolve the problem on documentation, but this bug is not only about documentation, it also affects database consistency.

To my mind it's not a standard having two inverted columns in a database. Especially if they touch account_move_lines which is very used by accountancy.

Revision history for this message
DBR (OpenERP) (dbr-openerp) wrote :

Hello Olivier,

This issue is not reproduced at our end.
Would you please update your code and recheck it?
and still problem occurred than you can reopen this bug.

Thanks.

Revision history for this message
Olivier DOSSMANN (odossmann) wrote :

Server: revno. 3322
Client-web: revno. 4468
Addons: revno. 4380

1. Create a new database, like test_inversion
2. Add account module
3. Create one CashBox in Bank and Cash
4. Open this CashBox, then close it.
5. Create a new one and open it
6. Create 2 cash transactions
7. Do what is necessary to close the cashbox (add some money into cashbox) then close it
8. Go to the database with "psql test_inversion"
9. Do this :
    \d account_bank_statement_line_move_rel

It returns this :
"account_bank_statement_line_move_rel_move_id_fkey" FOREIGN KEY (move_id) REFERENCES account_bank_statement_line(id) ON DELETE CASCADE
"account_bank_statement_line_move_rel_statement_id_fkey" FOREIGN KEY (statement_id) REFERENCES account_move(id) ON DELETE CASCADE

That show us that a statement_id references an account move ??? And a move_id references an account bank statement line ???

It's not a problem of integrity or function error. It's just a consistency problem.

You can easily understand that by requesting the content of the table :

    select * from account_bank_statement_line_move_rel;
    select * from account_move;
    select * from account_bank_statement_line;

Link all ids you see. They seems not to be where they should be.

The branch I put forward aims to resolve this.

Changed in openobject-addons:
status: Invalid → New
Amit Parik (amit-parik)
Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 3 (openerp-dev-addons3)
importance: Undecided → Low
status: New → Confirmed
Changed in openobject-addons:
status: Confirmed → In Progress
Revision history for this message
Meera Trambadia (OpenERP) (mtr-openerp) wrote :

Hello Olivier DOSSMANN,

I have merged your branch with the following branch:-
https://code.launchpad.net/~openerp-commiter/openobject-addons/trunk-dev-addons3-mtr1 branch.
Revision ID: mtr@mtr-20110127121721-j3i1np6ku2craczs
Revision no: 4714

Thanks for your contribution.

Thanks
mtr

Changed in openobject-addons:
status: In Progress → Fix Committed
Changed in openobject-addons:
status: Fix Committed → 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.