Files
odoo_source/addons/event/models/res_partner.py
T
RomainLibert c0618d72d0 [FIX] event: use sudo to compute event_count
You could not see the partner page when not having the event rights.
2018-06-08 16:33:45 +02:00

21 lines
786 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
class ResPartner(models.Model):
_inherit = 'res.partner'
event_count = fields.Integer("Events", compute='_compute_event_count', help="Number of events the partner has participated.")
def _compute_event_count(self):
for partner in self:
partner.event_count = self.env['event.event'].sudo().search_count([('registration_ids.partner_id', 'child_of', partner.ids)])
@api.multi
def action_event_view(self):
action = self.env.ref('event.action_event_view').read()[0]
action['context'] = {}
action['domain'] = [('registration_ids.partner_id', 'child_of', self.ids)]
return action