I have a computed field in a model called page_price.
Class Page(models.Model):
page_price = fields.Float(compute='compute_page_price')
def compute_page_price(self):
self.page_price = 7 # this value is an example
If I show this field in a view, it shows 7.
The problem is when I try to get the value from another model.
Class Book(models.Model):
book_price = fields.Float(compute='compute_book_price')
def compute_book_price(self):
# page_id has the value of a Page row id
page_price = self.env['Page'].search([('id', '=', page_id)])[0].page_price
self.book_price = page_price * 10
Here, the value of book_price is always 0 instead of 70.
The vaule of page_price inside the compute_book_price function is 0 instead of 7.
Why is that and how can I obtain the correct value?
Note: If the page_price field is defined as a Float field instead of a computed field, the result of book_price is 70.