c2c-oerpscenario team mailing list archive
-
c2c-oerpscenario team
-
Mailing list archive
-
Message #08034
[Bug 558658] Re: many2many: unique constraint missing
The fix has landed in trunk with revision 3110 revision-id:
odo@xxxxxxxxxxx-20101214132840-q7x2oodu6hez9d91.
It includes both a unique SQL constraint for m2m relation tables, but
also a double-check in fields.many2many.set() to avoid creating
duplicate records when [(4,X)] syntax is used to write to a m2m field.
Thanks for reporting!
Note: the unique constraint will be added only in newly created
databases.. otherwise it will require manual addition.
** Changed in: openobject-server
Status: In Progress => Fix Released
--
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/558658
Title:
many2many: unique constraint missing
Status in OpenObject Server:
Fix Released
Bug description:
Hi!
There is a problem with the data integrity of relations stored in many2many
fields. Currently code in OpenERP assumes that many2many relations doesn't have
duplicates (object1 is not connected to object2 more than one time). However,
those tables that store many2many relations allow the same object_id pairs get
duplicated, and when that happens, code that uses the many2many field starts to
misbehave.
Examples:
-Although the client theoretically doesn't allow this, a user managed to add
the same sales tax to a product two times. The client doesn't display the same
tax twice but the tax computing method in account.tax computes a double
amount. You can imagine, with lots of products, how difficult it is to spot this
kind of problems.
-Adding relations one-at-a-time to a many2many field with [(4, object_id)]
doesn't check if that relation has already been added or not.
IMHO if the ORM set unique(object1_id,object2_id) for the relation tables
would ensure that we are free from this kind of errors.