December 2018
Beginner to intermediate
404 pages
10h 14m
English
The computed field we just created can be read, but it can't be searched or written to. By default, computed field values are written on the fly, and are not stored in the database. That's why we can't search them like we can regular fields.
We can enable these search and write operations by implementing specialized functions for them. Along with the compute function, we can also set a search function to implement the search logic, and the inverse function to implement the write logic.
Using these, our computed field declaration looks as follows:
# class Book(models.Model): publisher_country_id = fields.Many2one( 'res.country', string='Publisher Country', compute='_compute_publisher_country', # store ...
Read now
Unlock full access