Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
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)
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 6/5/14, 9:55 AM|
|Seen: 2322 times|
|Last updated: 3/16/15, 8:10 AM|