~openerp-dev/openobject-server/saas-3-bug_1291322-ptr

« back to all changes in this revision

Viewing changes to openerp/addons/base/res/res_partner.py

  • Committer: Christophe Simonis
  • Date: 2014-04-04 15:58:58 UTC
  • mfrom: (4743.1.531 unaccentwrapper)
  • Revision ID: chs@openerp.com-20140404155858-mvupqmuvi8ime2tl
[MERGE] forward port of branch 7.0 up to revid 5274 chs@openerp.com-20140404141611-qi1yagltvkd9q8ji

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from openerp import SUPERUSER_ID
29
29
from openerp import tools
30
30
from openerp.osv import osv, fields
 
31
from openerp.osv.expression import get_unaccent_wrapper
31
32
from openerp.tools.translate import _
32
33
 
33
34
class format_address(object):
231
232
        'display_name': fields.function(_display_name, type='char', string='Name', store=_display_name_store_triggers, select=True),
232
233
        'date': fields.date('Date', select=1),
233
234
        'title': fields.many2one('res.partner.title', 'Title'),
234
 
        'parent_id': fields.many2one('res.partner', 'Related Company'),
 
235
        'parent_id': fields.many2one('res.partner', 'Related Company', select=True),
235
236
        'child_ids': fields.one2many('res.partner', 'parent_id', 'Contacts', domain=[('active','=',True)]), # force "active_test" domain to bypass _search() override
236
237
        'ref': fields.char('Reference', size=64, select=1),
237
238
        'lang': fields.selection(_lang_get, 'Language',
629
630
            if operator in ('=ilike', '=like'):
630
631
                operator = operator[1:]
631
632
 
632
 
            query = ('SELECT id FROM res_partner ' +
633
 
                     where_str +  '(email ' + operator + ''' %s
634
 
                          OR display_name ''' + operator + ''' %s)
635
 
                    ORDER BY display_name''')
 
633
            unaccent = get_unaccent_wrapper(cr)
 
634
 
 
635
            query = """SELECT id
 
636
                         FROM res_partner
 
637
                      {where} ({email} {operator} {percent}
 
638
                           OR {display_name} {operator} {percent})
 
639
                     ORDER BY {display_name}
 
640
                    """.format(where=where_str, operator=operator,
 
641
                               email=unaccent('email'),
 
642
                               display_name=unaccent('display_name'),
 
643
                               percent=unaccent('%s'))
636
644
 
637
645
            where_clause_params += [search_name, search_name]
638
646
            if limit: