April 2019
Beginner to intermediate
774 pages
24h 59m
English
Edit the models/library_book.py file to add the new related field:
from odoo import models, fields, api
class LibraryBook(models.Model):
# ...
@api.model def _referencable_models(self): models = self.env['ir.model'].search([ ('field_id.name', '=', 'message_ids')]) return [(x.model, x.name) for x in models]
ref_doc_id = fields.Reference(
selection='_referencable_models',
string='Reference Document')
Since we are changing the model's structure, a module upgrade is needed to activate these changes.
Read now
Unlock full access