Files
odoo_source/addons/hr/res_partner.py
T
Denis Ledoux 6e6e8ea185 [FIX] hr: mention suggestions for employees with disabled user
This is related to revision 84b45515bd

It's actually the user on which the `active` field  should be checked,
as this is possible to disable a user without disabling his partner,
but it should no longer be possible to mention him as soon
as the user is disabled.

opw-673719
2016-04-06 11:48:38 +02:00

23 lines
840 B
Python

# -*- coding: utf-8 -*-
from openerp import api, models
class Partner(models.Model):
_name = "res.partner"
_inherit = ['res.partner']
@api.model
def get_static_mention_suggestions(self):
""" Extend the mail's static mention suggestions by adding the employees. """
suggestions = super(Partner, self).get_static_mention_suggestions()
employee_group_id = self.env['ir.model.data'].xmlid_to_res_id('base.group_user')
self._cr.execute("""
SELECT P.id, P.name, P.email
FROM res_users U
INNER JOIN res_groups_users_rel R ON U.id = R.uid
INNER JOIN res_partner P ON P.id = U.partner_id
WHERE R.gid = %s AND U.active = 't'""", (employee_group_id,))
suggestions.append(self._cr.dictfetchall())
return suggestions