Listing inner fields in parent's tree view

Hi, is it possible to list inner fields in parent’s tree view?

For example in Author module’s tree view, I would like to list Books by this Author

books = fields.Many2One(‘author.books’,‘Books’)

  • Rowling
    • Harry Potter 1
    • Harry Potter 2
  • Bowling
    • Bowling Guide 1
    • Bowling Guide 2

Indeed you should use a One2Many from Author to books.
Once you have this field you can add it to the author modules tree view, but currently the One2Man widget on tree view only shows the number of records in the relation (but not the name).

If you wan to show the name you can use a Function field of char types. For example:

book_names = fields.Function(fields.Char("Books"), 'get_book_names')

def get_book_names(self, name):
     return ', '.join(b.rec_name for b in self.books)

Then if you add the book_names field on the list view you will see the list of books separated by a comma.

My bad, typo over there. Books is indeed fields.One2Many not Many2One

I was hoping they can be listed as nested tree views. But anyway thanks for this function, at least I’m able to show a preview of some of the names.

Normaly we use a relate action to open the books associated to an author.

Indeed it should be possible to create a nested tree view using probably an UnionMixin to show the name of the author and the name of all its books as children records. But then you will be only able to show the name of both models and it requires to create a custom module to join both of them.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.