[trunk] expression : search with child_of crashes if 'id' is created in openerp

Bug #1030942 reported by Benoit Guillot - http://www.akretion.com
This bug report is a duplicate of:  Bug #1131992: id child of not working on search. Edit Remove
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
New
Undecided
OpenERP Publisher's Warranty Team

Bug Description

In the file osv/expression.py, line 444 :
            if not field:
                if left == 'id' and operator == 'child_of':
                    ids2 = to_ids(right, table)
                    dom = child_of_domain(left, ids2, working_table)
                    self.__exp = self.__exp[:i] + dom + self.__exp[i+1:]
                else:
                    # field could not be found in model columns, it's probably invalid, unless
                    # it's one of the _log_access special fields
                    # TODO: make these fields explicitly available in self.columns instead!
                    if field_path[0] not in MAGIC_COLUMNS:
                        raise ValueError("Invalid field %r in domain expression %r" % (left, exp))
                continue

If the field 'id' is created in openerp, for a search with child_of, the method crashes because it doesn't pass in the code. Indeed, in that case "field" is not empty.

In my opinion, a search with child_of should support if the field exists in openerp or not.

Regards,

Benoît

Tags: maintenance
Changed in openobject-server:
assignee: nobody → OpenERP Publisher's Warranty Team (openerp-opw)
tags: added: maintenance
Revision history for this message
Hardik Ansodariya (OpenERP) (han-tinyerp) wrote :

Can you please provide us a working scenario that reproduce the issue with code that you have written in search domain?

Changed in openobject-server:
status: New → Incomplete
Revision history for this message
Benoit Guillot - http://www.akretion.com (benoit-guillot-z) wrote :

Hello,

To reproduce the issue, you need to create a small module which add the field : 'id' in openerp
I did it on the class account_account like so :

class account_account(osv.osv):

    _inherit = "account.account"

    _columns = {
        'id': fields.integer('Id'),
    }

Then in a method I had to make a search on the children of an account like so :

   for account in self.browse(cr, uid, ids, context=context):
        for children in account.child_parent_ids:
            self.unlink(cr, uid, [children.id], context=context)

The method unlink on the class account_account call the method : _check_moves, and this method have a search with child_of :
        account_ids = self.search(cr, uid, [('id', 'child_of', ids)])

In that case, the field 'id' exists on the account so the search on the child_of doesn't pass in the code :
            if not field:
                if left == 'id' and operator == 'child_of':
                    ids2 = to_ids(right, table)
                    dom = child_of_domain(left, ids2, working_table)
                    self.__exp = self.__exp[:i] + dom + self.__exp[i+1:]

I hope I have been more clear, if you still need some precisions I will glad to answer more.

Best regards,

Benoît

Changed in openobject-server:
status: Incomplete → New
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.