2018-01-16 06:58:15 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2018-01-16 11:34:37 +01:00
|
|
|
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
|
2018-01-16 06:58:15 +01:00
|
|
|
|
2018-01-16 11:34:37 +01:00
|
|
|
from flectra import api, fields, models
|
2018-01-16 06:58:15 +01:00
|
|
|
|
|
|
|
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'].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
|