[FIX] rating: return correct last rating value
Before this commit, the last rating value returned was not the last
consumed one.
closes odoo/odoo#61868
Taskid: 2260685
X-original-commit: 5fd11c46a4a12ffb977b15511e6eaf744cd8e0b6
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Kevin Baptiste <kba@odoo.com>
This commit is contained in:
@@ -59,10 +59,10 @@ class RatingMixin(models.AbstractModel):
|
||||
rating_count = fields.Integer('Rating count', compute="_compute_rating_stats", compute_sudo=True)
|
||||
rating_avg = fields.Float("Rating Average", compute='_compute_rating_stats', compute_sudo=True)
|
||||
|
||||
@api.depends('rating_ids.rating')
|
||||
@api.depends('rating_ids.rating', 'rating_ids.consumed')
|
||||
def _compute_rating_last_value(self):
|
||||
for record in self:
|
||||
ratings = self.env['rating.rating'].search([('res_model', '=', self._name), ('res_id', '=', record.id)], limit=1)
|
||||
ratings = self.env['rating.rating'].search([('res_model', '=', self._name), ('res_id', '=', record.id), ('consumed', '=', True)], limit=1)
|
||||
record.rating_last_value = ratings and ratings.rating or 0
|
||||
|
||||
@api.depends('rating_ids.res_id', 'rating_ids.rating')
|
||||
|
||||
Reference in New Issue
Block a user