Hi all,
i want to make the list of booked Events available on employee form in odoo 11. Therefore I query Event.registration for a given Partner ID and intend to put the corresponding Event in a one2many field on employee form. However, the one2many field events_per_user remains empty. The result of the query on Event.registration is valid, though.
I appreciate any help on this!
class Employee(models.Model):
_name = "hr.employee"[...]
events_per_employee = fields.One2many('event.event', compute='_compute_event_list')
def _compute_event_list(self):
#get related Partner, as there a n related Partners (Private adress, Company, ...)partnerID = self[0].user_id.partner_id.id
event_list = self.env['event.registration'].search([('partner_id', '=', partnerID)])
for event in event_list:
if(event.event_id):
print(event.event_id.id)
self.events_per_employee.write({'id': event.event_id.id})
[...]