December 2018
Beginner to intermediate
404 pages
10h 14m
English
A many-to-one relationship is a reference to a record in another model. For example, in the library book model, the publisher_id field represents the book publisher, and is a reference to a record in the partner model:
publisher_id = fields.Many2one( 'res.partner', string='Publisher')
The Many2one fields, first positional argument is the related model (the comodel keyword argument), as is the case for all relational fields.
The second positional argument is the field label (the string keyword argument), but this is not the case for the other relational fields, so the preferred option is to always use string as a keyword argument, as we did in the previous code.
A many-to-one Model field creates a field in the ...
Read now
Unlock full access