← Back to team overview

openerp-india team mailing list archive

[Bug 1090996] [NEW] trunk : Difficult to search based on relational fields

 

Public bug reported:

Guys,

Addressing several issues. Unable to decide this bug should be a part of
server/addons/web, but putting it into addons and web as it majorly
relate to them.

I found it difficult to search on relational fields.

Example:
I went to journal items and wanted to search based on accounts. I went to search panel, typed out the account, system gave me some options, I chose one....BOOM ...error.

A. **WEB does not let me select any raw name/half name. Rather it forces
me to select any record for search (like I could not search on Serp , I
had to select the whole account 404 SerpentCS. **

Error was bad query code ilike somename.  Well , this is an error I saw
somewhere on launchpad.

I fixed it by :
<field name="account_id" filter_domain="['|', ('account_id.name', 'ilike', self), ('account_id.code', 'ilike', self)]"/>

B. **Relational wherever used should have the domain better managed as
field_name.internal field as the search is going to hit the main model,
not a relational one. So, It should be account_id.code . not code!**

I ran the same procedure, no crash, but no crash does not mean its
working!

The domain created was : ['|', ('account_id.name', 'ilike', '404
SerpentCS'), ('account_id.code', 'ilike', '404 SerpentCS')]

C. **Had I have a domain ('account_id.code', 'ilike', 'SerpentCS'), I
would have got my search working. But here the condition does a check of
ILIKE. I prefer it should better be '=' as web always forces to select a
ready record. **

You would suggest me to use Advanced filter, alright. Lets go there!

D. Search, name_search for each relational field needs to be addressed
well wherever the name_get is overridden.

I went to advanced search and chose 'Account' - Contains - 11. System
created a domain [['account_id', 'ilike', '11']] which is going to
name_search.

Comes another issue, we always assume that the search string STARTSWITH
11, but its not always the case. In order to get this working,I had to
change the line (of name_search of account)

ids = self.search(cr, user, [('code', '=like', name+"%")]+args,
limit=limit)

TO

ids = self.search(cr, user, [('code', '=like', '%'+name+"%")]+args,
limit=limit)

And,finally it worked for me.

Hope you understood.

Thanks,
Serpent Consulting Services!

** Affects: openerp-web
     Importance: Undecided
         Status: New

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

** Also affects: openerp-web
   Importance: Undecided
       Status: New

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

Title:
  trunk : Difficult to search based on relational fields

Status in OpenERP Web:
  New
Status in OpenERP Addons (modules):
  New

Bug description:
  Guys,

  Addressing several issues. Unable to decide this bug should be a part
  of server/addons/web, but putting it into addons and web as it majorly
  relate to them.

  I found it difficult to search on relational fields.

  Example:
  I went to journal items and wanted to search based on accounts. I went to search panel, typed out the account, system gave me some options, I chose one....BOOM ...error.

  A. **WEB does not let me select any raw name/half name. Rather it
  forces me to select any record for search (like I could not search on
  Serp , I had to select the whole account 404 SerpentCS. **

  Error was bad query code ilike somename.  Well , this is an error I
  saw somewhere on launchpad.

  I fixed it by :
  <field name="account_id" filter_domain="['|', ('account_id.name', 'ilike', self), ('account_id.code', 'ilike', self)]"/>

  B. **Relational wherever used should have the domain better managed as
  field_name.internal field as the search is going to hit the main
  model, not a relational one. So, It should be account_id.code . not
  code!**

  I ran the same procedure, no crash, but no crash does not mean its
  working!

  The domain created was : ['|', ('account_id.name', 'ilike', '404
  SerpentCS'), ('account_id.code', 'ilike', '404 SerpentCS')]

  C. **Had I have a domain ('account_id.code', 'ilike', 'SerpentCS'), I
  would have got my search working. But here the condition does a check
  of ILIKE. I prefer it should better be '=' as web always forces to
  select a ready record. **

  You would suggest me to use Advanced filter, alright. Lets go there!

  D. Search, name_search for each relational field needs to be addressed
  well wherever the name_get is overridden.

  I went to advanced search and chose 'Account' - Contains - 11. System
  created a domain [['account_id', 'ilike', '11']] which is going to
  name_search.

  Comes another issue, we always assume that the search string
  STARTSWITH 11, but its not always the case. In order to get this
  working,I had to change the line (of name_search of account)

  ids = self.search(cr, user, [('code', '=like', name+"%")]+args,
  limit=limit)

  TO

  ids = self.search(cr, user, [('code', '=like', '%'+name+"%")]+args,
  limit=limit)

  And,finally it worked for me.

  Hope you understood.

  Thanks,
  Serpent Consulting Services!

To manage notifications about this bug go to:
https://bugs.launchpad.net/openerp-web/+bug/1090996/+subscriptions


Follow ups

References