can anbody tell me override name_get method in new api
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Boekhouding
- Voorraad
- PoS
- Project
- MRP
Deze vraag is gerapporteerd
In the new api, it's the field display_name. Just override the field display name to a computed one.
class res_partner(Model):
...display_name = fields.Char(
string='Name', compute='_compute_display_name',
)@api.one
@api.depends('name', 'parent_id.name')
def _compute_display_name(self):
names = [self.parent_id.name, self.name]
self.display_name = ' / '.join(filter(None, names))
Learn – Overriding name_get method in Odoo 8 with Example & Screenshots - Odoo Technical
http://odootechnical.com/overriding-name_get-method-in-odoo-8/
I had some problems with this until I read this post by Martin Trigaux in the mailing list:
https://www.odoo.com/groups/community-59/community-8908652
Perhaps is a good idea to update the docs.
Hello, Sorry to contradict you but it's actually still name_get that you should override. The initial intended behaviour was indeed to have display_name as replacement of name_get. However there were lot's of issues with the initial implementation and it was not backward compatible with the old api and we have to partially go back to old behaviour[1].
So the current behaviour of the name_get/display_name is the following:
name_get is still the main function used for rendering display_name is a computed field that will use name_get If you want to change both, you should still override name_get (see event for example[2]).
Changing the method of display_name would affect only display_name, not name_get (can be what we want[3] but usually not).
We may change one day to fully use display_name and drop name_get but that means breaking the backward-compatibility.
Hope it's clear.
[1] https://github.com/odoo/odoo/commit/f138aa26085d103a88dbd8bb73fb8bf5517298ad
[2] https://github.com/odoo/odoo/blob/8.0/addons/event/event.py#L194
[3] https://github.com/odoo/odoo/blob/8.0/openerp/addons/base/res/res_partner.py#L232
--
Martin Trigaux Odoo (Formerly OpenERP)
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
AanmeldenGerelateerde posts | Antwoorden | Weergaven | Activiteit | |
---|---|---|---|---|
|
3
mei 20
|
7782 | ||
|
6
mrt. 16
|
25891 | ||
|
1
mrt. 15
|
8463 | ||
What is the use of @api.returns?
Opgelost
|
|
2
jan. 20
|
15657 | |
|
0
jan. 17
|
11181 |