Integrity error on many2many when using inheritance by prototyping

Bug #1207694 reported by Karel Marissens
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
New
Undecided
OpenERP Publisher's Warranty Team

Bug Description

Simple case:
Model A defines a many2many field to model X.
Model B inherits from model A but defines a new name (thus: inheritance by prototyping).

When creating an object of model B, an integrity error occurs. When looking in the console, this is the underlying error:

2013-08-02 12:01:43,125 6440 ERROR test01 openerp.sql_db: bad query: insert into model_a_model_x_rel (model_a_id,model_x_id) values (37, 6)
Traceback (most recent call last):
  File "C:\...\openerp-server\openerp\sql_db.py", line 226, in execute
    res = self._obj.execute(query, params)
IntegrityError: insert or update on table "model_a_model_x_rel" violates foreign key constraint "model_a_model_x_rel_model_a_id_fkey"
DETAIL: Key (model_a_id)=(37) is not present in table "model_a".

By doing the inheritance by prototyping, the definition of the many2many field is copied from model a to model b. Thus, the many2many in model b defines the same relational table for storing the relation. Since model b is another table altogether, this doesn't work.

A workaround is to do an overwrite of the many2many in model b to define another relational table, but shouldn't this happen automatically? The same problem could possibly happen with one2many fields (not tested).

Tags: maintenance
Changed in openobject-addons:
assignee: nobody → OpenERP Publisher's Warranty Team (openerp-opw)
tags: added: maintenance
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.