Odoo Help

0

Expression parsing sequence

By
Ivan
on 1/27/15, 2:42 AM 1,017 views

Dear all,

In light of a problem that I have, I've submitted an Issue at Odoo's github.

However I still wonder if there is any way to workaround this.  The issue is, I have model A which have a delegation inheritance (_inherits) from model B.  Below is a very simplified illustration of the set-up.

class A(orm.Model):

    _inherits: {'model.b': 'model_b_id'}

    _columns = {

        'model_b_id': fields.many2one('model.b', 'Model B')

    }

Now, 'id' column is usually not defined in model's _column.  But in model B has column 'id' redefined because it is needed in the view to specify a context.  Thus I have model A that does not have 'id' column explicitly defined inherits from model B that has column 'id' redefined.

The problem is that when I executed a method (say click a button) from model A's view, it will search model A with domain like [['id', 'in', [999]]].  When the domain expression is parsed.  It will check if the 'id' column is in model A's _columns.  As it couldn't find it, it will check agains with the following sequence:

  1. ... some unrelated prior checks omitted
  2. check if the column exists in the _inherited_columns --> Here, in my situation, the field can be found.
  3. check if the column is 'id' and that the operator is 'child_of'
  4. check if the column is one of the MAGIC_COLUMNS (for now they are 'id', 'create_uid', 'create_date', 'write_uid', 'write_date)
  5. ... some unrelated other checks omitted

Since expression can find the field in step 2, it will "think" that the code is searching the 'id' column of model B, which is incorrect.

One workaround I can think of is to re-define the 'id' column in model A.  I'm wondering if there is any other workaround.

Thank you.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 1/27/15, 2:42 AM
Seen: 1017 times
Last updated: 3/16/15, 8:10 AM