Community mailing list archives

community@mail.odoo.com

Re: name_get(self)

by
Arjan Duijs
- 11/26/2016 15:34:35
Í have gotten the analytic account is working, and is being displayed next to the project name.
But in order to being able to search on the code as well i tried the following name_search code.

In the search method the analytic_account_id.id is generating an error because of it is being an INT.
tried casting it to str() but that even generated more errors

below is my code

@api.model
def name_search(self, name='', args=None, operator='ilike', limit=100):
if operator not in ('ilike', 'like', '=', '=like', '=ilike'):
return super(AccountAnalyticAccount, self).name_search(name, args, operator, limit)
args = args or []
domain = ['|', ('analytic_account_id.id', operator, name), ('name', operator, name)]
partners = self.env['res.partner'].search([('name', operator, name)], limit=limit)
if partners:
domain = ['|'] + domain + [('partner_id', 'in', partners.ids)]
recs = self.search(domain + args, limit=limit)
return recs.name_get()

ProgrammingError: operator does not exist: integer ~~* unknown
LINE 1: ... AND  (("project_project__analytic_account_id".id ilike ''  ...
                                                             ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

I tried changing the operator to '=' but that didnt help either.

any ideas?