This commit contains mainly code cleaning, docstrings and a small split
for notification tool methods. In this commit we
* make some notification groups variable explicit;
* move the filler of groups into its own submethod to ease being called
from other code (to be used soon);
* fix some strange overrides or code manipulation;
* propagate some additional parameters to ease future commits that will
improve rendering of groups-based notification emails;
* cleanup, fixup and improve docstrings;
This does not change anything from functional point of view, just preparing
further work.
Task-3046371 (Mail: Better Language Support in Composer)
Part-of: odoo/odoo#106177
30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import models
|
|
|
|
|
|
class Followers(models.Model):
|
|
_inherit = ['mail.followers']
|
|
|
|
def _get_recipient_data(self, records, message_type, subtype_id, pids=None):
|
|
recipients_data = super()._get_recipient_data(records, message_type, subtype_id, pids=pids)
|
|
if message_type != 'sms' or not (pids or records):
|
|
return recipients_data
|
|
|
|
if pids is None and records:
|
|
records_pids = dict(
|
|
(record.id, record._sms_get_default_partners().ids)
|
|
for record in records
|
|
)
|
|
elif pids and records:
|
|
records_pids = dict((record.id, pids) for record in records)
|
|
else:
|
|
records_pids = {0: pids if pids else []}
|
|
for rid, rdata in recipients_data.items():
|
|
sms_pids = records_pids.get(rid) or []
|
|
for pid, pdata in rdata.items():
|
|
if pid in sms_pids:
|
|
pdata['notif'] = 'sms'
|
|
return recipients_data
|