There's more...

Record representation is available in a magic display_name computed field, and has been added automatically 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 Odoo versions.

The default implementation of name_get() uses the _rec_name attribute to find which field holds the data; that should use to generate the display name. For more sophisticated representations, we can override its logic. 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: 
    result.append( 
    (record.id,  
    "%s (%s)" % (record.name, record.date_release) 
     )) 
return result 
..................Content has been hidden....................

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