← Back to team overview

openerp-india team mailing list archive

[Bug 1013603] [NEW] search() is not called when name_search() not defined

 

Public bug reported:

Hi,

I face an issue with search() method. Let me take an example for more
clear. There are 2 classes: A, B

===
class A(osv.osv):

    def search():

    return super(A, self).search(....)

A()

class B(osv.osv):

   _columns = {
      a_id: many2one('A')....
  }

B()
===

Now, I open the form of model B and edit it, I choose a value of a_id.
A.search() is not executed.

But if I define name_search() for A as follow:

===
def name_search():
    self.search(...)
    return self.name_get(cr, uid, ids, context=context)
===

Then A.search() is executed due to explicit called by self.search()
inside name_get().

This is actual issue when I do some customizations on search of A. For
example, I define a domain for a_id as [('code','child_of','abc')].
Without name_get(), it will fail with domain error. With name_get()
defined, it can do as expected.

After many tests, I see that search() of a model must be called explicit
through other methods (name_get() here), otherwise it will fail, can't
do any customizations on domain search.

I think that orm should call search() overriden method of model at any
time. my above tests show that orm calls search() of osv.osv.

Thanks,

** Affects: openobject-server
     Importance: Undecided
         Status: New

-- 
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/1013603

Title:
  search() is not called when name_search() not defined

Status in OpenERP Server:
  New

Bug description:
  Hi,

  I face an issue with search() method. Let me take an example for more
  clear. There are 2 classes: A, B

  ===
  class A(osv.osv):

      def search():

      return super(A, self).search(....)

  A()

  class B(osv.osv):

     _columns = {
        a_id: many2one('A')....
    }

  B()
  ===

  Now, I open the form of model B and edit it, I choose a value of a_id.
  A.search() is not executed.

  But if I define name_search() for A as follow:

  ===
  def name_search():
      self.search(...)
      return self.name_get(cr, uid, ids, context=context)
  ===

  Then A.search() is executed due to explicit called by self.search()
  inside name_get().

  This is actual issue when I do some customizations on search of A. For
  example, I define a domain for a_id as [('code','child_of','abc')].
  Without name_get(), it will fail with domain error. With name_get()
  defined, it can do as expected.

  After many tests, I see that search() of a model must be called
  explicit through other methods (name_get() here), otherwise it will
  fail, can't do any customizations on domain search.

  I think that orm should call search() overriden method of model at any
  time. my above tests show that orm calls search() of osv.osv.

  Thanks,

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


Follow ups

References