Hi, i've got to change the search mode for the many2one field 'bank' of res.partner.bank to make it search for the 'bank_bic' rather than the 'bank_name' or make it search on the whole string returned by the field as my DB contains lots of data like that:
name | bic
UBS AG | UBSWCHZH50A
UBS AG | UBSWCHZH90A
UBS AG | UBSWCHZH84A
selection field output is like that :
UBSWCHZH90A - UBS AG
UBSWCHZH84A - UBS AG
I tried to add some domain and domain_filter in the xml and in the python field but it didn't work.
Here is the python field :
'bank':fields.many2one('res.bank','Bank',domain_filter="[('bank_bic','ilike',self)]") (causes no error but don't work)
And here is my xml :
<field name="bank" on_change="onchange_bank_id(bank)"/>
Is it possible ?
Thank you in advance
Based on your reqirement to override name_get and name_search method in res_bank class.
Default res_bank name_get code:-
def name_get(self, cr, uid, ids, context=None):
result = 
for bank in self.browse(cr, uid, ids, context):
result.append((bank.id, (bank.bic and (bank.bic + ' - ') or '') + bank.name))
In the above code output value display in the dropdown list based on your need to override the method.
If yor want to change the search behaviour then override name_search method.
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100):
if not args:
args = 
ids = self.search(cr, user, [('name','=',name)]+ args, limit=limit, context=context)
ids = self.search(cr, user, args, limit=limit, context=context)
result = self.name_get(cr, user, ids, context=context)
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
|Asked: 6/5/14, 9:55 AM|
|Seen: 2029 times|
|Last updated: 3/16/15, 8:10 AM|