← Back to team overview

openerp-india team mailing list archive

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

 

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

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Server.
https://bugs.launchpad.net/bugs/1030942

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

Status in OpenERP Server:
  Incomplete

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

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/1030942/+subscriptions


References