You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

38 lines
1.4 KiB

# Copyright 2019 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models, modules
class Users(models.Model):
_inherit = 'res.users'
review_ids = fields.Many2many(
string="Reviews", comodel_name="tier.review"
)
@api.model
def review_user_count(self):
user_reviews = {}
to_review_docs = {}
for review in self.env.user.review_ids.filtered(
lambda r: r.status == 'pending'):
record = review.env[review.model].browse(review.res_id)
if not user_reviews.get(review['model']):
user_reviews[review.model] = {
'name': record._description,
'model': review.model,
'icon': modules.module.get_module_icon(
self.env[review.model]._original_module),
'pending_count': 0
}
docs = to_review_docs.get(review.model)
if (docs and record not in docs) or not docs:
user_reviews[review.model]['pending_count'] += 1
to_review_docs.setdefault(review.model, []).append(record)
return list(user_reviews.values())
@api.model
def get_reviews(self, data):
return self.env['tier.review'].search_read(
[('id', 'in', data.get('res_ids'))])