[FIX] mail: do no try to send notification to inactive users

- This commit prevent to send notifications to inactive users.
- This fixes a bug where two partners have been merged and one of its
  users is archived.

  If one of the two users is inactive the code might use its `notification
  type` preferences instead of the active user's one.

closes odoo/odoo#28730
This commit is contained in:
Toufik Ben Jaa
2018-11-16 11:13:56 +00:00
parent 8ee02ad136
commit 6f7262f508
+2 -2
View File
@@ -114,7 +114,7 @@ SELECT partner.id as pid, NULL AS cid,
partner.active as active, partner.partner_share as pshare, NULL as ctype,
users.notification_type AS notif, array_agg(groups.id) AS groups
FROM res_partner partner
LEFT JOIN res_users users ON users.partner_id = partner.id
LEFT JOIN res_users users ON users.partner_id = partner.id AND users.active
LEFT JOIN res_groups_users_rel groups_rel ON groups_rel.uid = users.id
LEFT JOIN res_groups groups ON groups.id = groups_rel.gid
WHERE EXISTS (
@@ -148,7 +148,7 @@ SELECT partner.id as pid, NULL AS cid,
partner.active as active, partner.partner_share as pshare, NULL as ctype,
users.notification_type AS notif, NULL AS groups
FROM res_partner partner
LEFT JOIN res_users users ON users.partner_id = partner.id
LEFT JOIN res_users users ON users.partner_id = partner.id AND users.active
WHERE partner.id IN %s"""
params.append(tuple(pids))
if cids: