summaryrefslogtreecommitdiff
path: root/addons/mail/wizard/invite.py
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2019-05-22 15:10:54 +0000
committerThibault Delavallée <tde@odoo.com>2019-07-12 14:54:11 +0000
commit488a5d5af5418ed5c223af5b61aea0b3100508c1 (patch)
tree796bf1e455b263f39800040b7f9f3d7c7756dc16 /addons/mail/wizard/invite.py
parentfd15ca19183a765e1307c4d197bf0dda30b73ab7 (diff)
[IMP] mail: prepare new SMS model by updating mail.notification
This commit prepares SMS refactoring by updating some mail models. Purpose is to be able to store SMS notification information inside existing mail flow and models. Main changes * mail.notification: define a notification_type field to store the medium used to notify people. In mail two ways exist: inbox and email. It will ease introduction of SMS notification mechanism. This field replaces the is_email boolean field; * mail.notification: make res_partner_id field not required. This means notifications could be linked to something else than a partner. An SMS for example. For Inbox and email notifications partner is still required and a constraint is added accordingly; * mail.thread: let notification methods handle the creation and update of their notification instead of creating them in _notify_thread and tweaking them in sub notification methods; * mail.thread: clearly move inbox-style notification in its own method like notify by email; Some lighter code changes * propagate message_type to notification recipient computation. It will allow for example to be more precise when computing a notification type depending on the message_type. For example, send a notification by SMS when the message_type is SMS; * ease inheritance of ``_notify_thread`` by returning computed recipients data. It will allow to work on it without having to re-compute it; * propagate kwargs from message_post and message_notify to notify methods. This allow to avoid depending on context and set explicit parameters. Drawback is that message_post and notify must separate kwargs used to create a message and those that are propagated to notification methods; * update various notification check to ensure they work on email notifications, notably the resend and cancel wizards; One side effect of this commit is that notifications are created by the relevant notification method. Previously all notifications were created by writing on needaction_partner_ids fields then updated according to the notification process. Notably there could be too much notification created when sending emails due to _notify_customize_recipients not being correctly synchronized with notification. This issue is now solved as only really sent emails create notifications. Migration tips * notification_type: notification.is_email and 'email' else 'inbox'; * remove is_email; Related to task 1922163 Linked to PR #33510
Diffstat (limited to 'addons/mail/wizard/invite.py')
-rw-r--r--addons/mail/wizard/invite.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/addons/mail/wizard/invite.py b/addons/mail/wizard/invite.py
index 5a899e1a7c6..5c7889b6a76 100644
--- a/addons/mail/wizard/invite.py
+++ b/addons/mail/wizard/invite.py
@@ -72,13 +72,13 @@ class Invite(models.TransientModel):
'no_auto_thread': True,
'add_sign': True,
})
- partners_data = [{
- 'id': pid,
- 'share': True,
- 'notif': 'email',
- 'type': 'customer',
+ recipients_data = {'partners': [{
+ 'id': pid,
+ 'share': True,
+ 'notif': 'email',
+ 'type': 'customer',
'groups': []
- } for pid in new_partners.ids]
- document._notify_record_by_email(message, partners_data, send_after_commit=False)
+ } for pid in new_partners.ids]}
+ document._notify_record_by_email(message, recipients_data, send_after_commit=False)
message.unlink()
return {'type': 'ir.actions.act_window_close'}