From ec27173d59a048b2cc66523b3fa46c6dae170df0 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Thu, 28 Feb 2019 15:48:26 +0000 Subject: [PATCH] [FIX] crm: team inherits alias, field definition Before this commit, in some cases, clicking on a crm.lead triggered a traceback saying "the column crm_team.alias_user_id does not exist" This was because the field alias_user_id on mail.activity.mixin, was itself _inherits from mail.alias In that case, "overriding" the field in the child class is actually a plain definition of the field, making it "loosing" its related nature After this commit, there is no traceback anymore closes odoo/odoo#31511 --- addons/crm/models/crm_team.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/crm/models/crm_team.py b/addons/crm/models/crm_team.py index 30d7cc945ea..a101fb26848 100644 --- a/addons/crm/models/crm_team.py +++ b/addons/crm/models/crm_team.py @@ -31,7 +31,10 @@ class Team(models.Model): compute='_compute_overdue_opportunities', string='Overdue Opportunities Revenues') - alias_user_id = fields.Many2one(domain=lambda self: [ + # Since we are in a _inherits case, this is not an override + # but a plain definition of a field + # So we need to reset the property related of that field + alias_user_id = fields.Many2one('res.users', related='alias_id.alias_user_id', inherited=True, domain=lambda self: [ ('groups_id', 'in', self.env.ref('sales_team.group_sale_salesman_all_leads').id)]) def _compute_unassigned_leads_count(self):