Community mailing list archives

community@mail.odoo.com

name_get(self)

by
Arjan Duijs
- 11/26/2016 14:20:37
Hi, I am trying to overwrite the display name of the project.
From what i read this is to e done with name_get(self)
I took the analitic code as an example (since i am trying to accomplish something like that  code + client.
But for the projects i am trying to concatenate its analytic account id (which is unique and could serve me well for a project number) with its name.

@api.multi
def name_get(self):
res = []
for project in self:
name = project.name
if project.name:
name = '['+project.analytic_account_id+'] '+name
res.append((project.id, name))
return res

but this is giving me an error

Odoo Server Error
Traceback (most recent call last):
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\http.py", line 638, in _handle_exception
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\http.py", line 675, in dispatch
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\http.py", line 331, in _call_function
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\service\model.py", line 119, in wrapper
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\http.py", line 324, in checked_call
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\http.py", line 933, in __call__
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\http.py", line 504, in response_wrap
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\addons\web\controllers\main.py", line 862, in call_kw
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\addons\web\controllers\main.py", line 854, in _call_kw
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\api.py", line 679, in call_kw
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\api.py", line 664, in call_kw_model
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\models.py", line 1586, in name_search
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\models.py", line 1601, in _name_search
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\addons\crm_project\models\project.py", line 24, in name_get
TypeError: cannot concatenate 'str' and 'account.analytic.account' objects

can someone explain why this number is in fact an acount.analytic.account object because in the DB it shows to me as a number

Inline afbeelding 1

and ofcourse, how i can solve this.

cheers