[FIX] models: display_name and name_get mismatch
authorMartin Trigaux <mat@openerp.com>
Wed, 16 Jul 2014 08:35:52 +0000 (10:35 +0200)
committerOlivier Dony <odo@openerp.com>
Fri, 25 Jul 2014 11:58:59 +0000 (13:58 +0200)
commitf138aa26085d103a88dbd8bb73fb8bf5517298ad
tree3b2c3db5a4da6ee1497cf312b2ddff4655c9aecd
parentbcd9456db594496cbf0f539f96c7bb09717b549c
[FIX] models: display_name and name_get mismatch

- display_name uses name_get and not the other way around:
name_get should not call _compute_display_name, _compute_display_name should call name_get.
The previous behaviour was not backward-compatible with the old api.
All the models redefining name_get would have 2 different behaviors between name_get and display_name.

- Do not set an inverse function to display_name:
In most cases, writing on display_name writes on _rec_name (if any, not mandatory).
If the display_name computation is redefined, we need to redefine as well the inverse method to avoid unexpected behaviour
This required to also modify tests in base_import as readonly fields are avoided.

- Remove search method on display_name:
For the same reason as for the first point, it could be good that searching on display_name use name_search (and not the other way around).
However doing this would be very inefficiant (need to do the search, without limit, extract the ids of the name_get result just to generate
a subdomain ('id', 'in', [...]). As in most cases it would anyway mean to search on the _rec_name it's better to directly do so.

- Changing label to avoid mismatch:
In view displaying the list of fields or when a match is made on the label of a field (e.g. when importing csv file,
matching is made on both label and technical name), the fact that display_name field has '
Calling it 'Display Name' will avoid most errors.

- remove display_name definition from website_forum_doc,ir_model:
These fields are doing the same thing as the display_name of the new api, we can remove them.
We need to keep the one for res.partner as it's a stored field.
addons/account/account_invoice.py
addons/base_import/tests/test_cases.py
addons/event/event.py
addons/website_forum_doc/models/documentation.py
openerp/addons/base/ir/ir_model.py
openerp/addons/base/res/res_bank.py
openerp/models.py