There's more...

Record representation is available in a magic display_name computed field, and has been automatically added to all models since version 8.0. Its values are generated using the name_get() model method, which was already in existence in the previous versions of Odoo.

The default implementation of name_get() uses the _rec_name attribute to find which field holds the data, which is used to generate the display name. If you want your own implementation for the display name, you can override the name_get() logic to generate a custom display name. The method must return a list of tuples with two elements: the ID of the record and the Unicode string representation for the record.

For example, to have the title and its release date in the representation, such as Moby Dick (1851-10-18), we can define the following:

def name_get(self):
result = []
for record in self:
rec_name = "%s (%s)" % (record.name, record.date_release)
result.append((record.id, rec_name))
return result
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset