April 2016
Beginner to intermediate
400 pages
9h 16m
English
With relational fields, we need to decide beforehand the relation's target model (or comodel). But sometimes, we may need to leave that decision to the user and first choose the model we want and then the record we want to link to.
With Odoo, this can be achieved using Reference fields.
We will reuse the my_module addon module from Chapter 3, Creating Odoo Modules.
Edit the
models/library_book.py file to add the new related field:
from openerp import models, fields, api class LibraryBook(models.Model): # … @api.model def _referencable_models(self): models = self.env['res.request.link'].search([]) ...