Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.
Module: Customer Rating
Entity: rating.mixin
Compute Method: _compute_rating_last_value
| Inputs | Method | Outputs |
|---|---|---|
|
self.flush_model(['rating_ids']) - self.env['rating.rating'].flush_model(['consumed', 'rating']) + self.env['rating.rating'].flush_model(['consumed', 'rating', 'res_id', 'res_model', 'write_date']) if not self.ids: self.rating_last_value = 0 return self.env.cr.execute(""" SELECT array_agg(rating ORDER BY write_date DESC, id DESC) AS "ratings", res_id as res_id FROM "rating_rating" WHERE res_model = %s AND res_id in %s AND consumed = true GROUP BY res_id""", [self._name, tuple(self.ids)]) read_group_raw = self.env.cr.dictfetchall() rating_by_res_id = {e['res_id']: e['ratings'][0] for e in read_group_raw} for record in self: record.rating_last_value = rating_by_res_id.get(record.id, 0) |
|
