Friday, January 8, 2010

Base, Fields, Search

AIM : To be able to search the functional field(function,related,property) on multilingual environment.


Changes:

As everybody knows that context plays a vital role in translations,we needed the translated values to be searched for functional fields.

1. bin/osv/fields.py

class function(_column)  --> def search(self, cr, uid, obj, name, args) has a new argument context.

Which appears now as def search(self, cr, uid, obj, name, args, context=None).

This context will help the search method to translate the keyword.

Example:
Follow these steps:
1. Install a minimal profile with demo data.
2. Load French language.
3. Switch to French environment(i.e.,User/Preferences to be set to fr_FR.
4. Go to Partners. (Belgium appears as belgique[translated value]) .
5. If we search belgiq, we won't find any records.
6. Reason : The keyword 'belgiq' was directly compared with DB values. It has to be the comparision between keyword and DISPLAYED value(we were in fr environment).
7. Pass context to your method  and have a try. (fnct_search=Method  would appear in your class definition of _columns.)
    account/account_move_line.py  has fnct_search=_invoice_search.
    so, def _invoice_search(self, cursor, user, obj, name, args) is now
          def _invoice_search(self, cursor, user, obj, name, args, context).

Programmers are requested to update the corresponding fnct_search methods with context argument appended to the method.


Thanks,
Regards,

Jay Vora,
E-Mail : jvo@tinyerp.com
(Not miles, just an e-mail away...)