[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
This commit is contained in:
Lucas Perais (lpe)
2019-02-28 15:48:26 +00:00
parent 8316c2d210
commit ec27173d59
+4 -1
View File
@@ -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):