From fdef51ea5774c136667750d85b829a297809d3d0 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 11 Mar 2022 09:01:32 +0100 Subject: [PATCH] account_usability: add name_search() on account.incoterms --- account_usability/models/account_incoterms.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/account_usability/models/account_incoterms.py b/account_usability/models/account_incoterms.py index 75f453e..ca2b842 100644 --- a/account_usability/models/account_incoterms.py +++ b/account_usability/models/account_incoterms.py @@ -14,3 +14,13 @@ class AccountIncoterms(models.Model): for rec in self: res.append((rec.id, '[%s] %s' % (rec.code, rec.name))) return res + + @api.model + def name_search(self, name='', args=None, operator='ilike', limit=100): + if args is None: + args = [] + if name and operator == 'ilike': + recs = self.search([('code', '=ilike', name + '%')] + args, limit=limit) + if recs: + return recs.name_get() + return super().name_search(name=name, args=args, operator=operator, limit=limit)