Community mailing list archives


Re: name_get(self)

Arjan Duijs
- 28 نوفمبر, 2016 10:28:34
Cheers, i was thinking in the line of Graeme as well, but didn't want to make an extra field if it wasn't necessary.
I have created a sequence for projects and that works like a charm with the name_get/search

2016-11-27 16:57 GMT-05:00 Daniel Reis <>:

No dia 26/11/2016, às 23:52, Graeme Gellatly <> escreveu:

You are probably better off having a stored char function field or separate sequence. Your only reliable way of doing name search your current way is to regex the search string, extract integers and then use those in search for account analytic id. No need to chain to id in the name search.

On Sun, 27 Nov 2016 9:37 AM Arjan Duijs <> wrote:
Í 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 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

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 = ['|', ('', 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 = + 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?

Post to:

Post to:

Post to: