Odoo Help

Welcome!

This community 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.

0

Expression parsing sequence

By
Ivan
on 1/27/15, 2:42 AM 689 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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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