odoo-addon-mail-gateway 17.0.1.0.0.2__py3-none-any.whl → 18.0.1.0.0.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of odoo-addon-mail-gateway might be problematic. Click here for more details.

Files changed (59) hide show
  1. odoo/addons/mail_gateway/README.rst +16 -6
  2. odoo/addons/mail_gateway/__init__.py +1 -0
  3. odoo/addons/mail_gateway/__manifest__.py +2 -1
  4. odoo/addons/mail_gateway/controllers/__init__.py +0 -1
  5. odoo/addons/mail_gateway/controllers/gateway.py +2 -2
  6. odoo/addons/mail_gateway/i18n/mail_gateway.pot +6 -52
  7. odoo/addons/mail_gateway/models/discuss_channel.py +24 -18
  8. odoo/addons/mail_gateway/models/mail_gateway.py +4 -4
  9. odoo/addons/mail_gateway/models/mail_gateway_abstract.py +1 -1
  10. odoo/addons/mail_gateway/models/mail_guest.py +6 -4
  11. odoo/addons/mail_gateway/models/mail_message.py +32 -14
  12. odoo/addons/mail_gateway/models/mail_notification.py +13 -6
  13. odoo/addons/mail_gateway/models/mail_thread.py +26 -12
  14. odoo/addons/mail_gateway/models/res_partner.py +0 -14
  15. odoo/addons/mail_gateway/models/res_users.py +3 -3
  16. odoo/addons/mail_gateway/readme/CONTRIBUTORS.md +3 -0
  17. odoo/addons/mail_gateway/readme/ROADMAP.md +1 -0
  18. odoo/addons/mail_gateway/security/security.xml +0 -1
  19. odoo/addons/mail_gateway/static/description/index.html +27 -16
  20. odoo/addons/mail_gateway/static/src/components/chatter/chatter.esm.js +2 -3
  21. odoo/addons/mail_gateway/static/src/components/chatter/chatter.xml +9 -3
  22. odoo/addons/mail_gateway/static/src/components/composer/composer.esm.js +3 -4
  23. odoo/addons/mail_gateway/static/src/components/gateway_follower/gateway_follower.esm.js +0 -1
  24. odoo/addons/mail_gateway/static/src/components/message/message.xml +3 -3
  25. odoo/addons/mail_gateway/static/src/components/message/message_patch.esm.js +7 -7
  26. odoo/addons/mail_gateway/static/src/core/common/composer_model_patch.esm.js +0 -1
  27. odoo/addons/mail_gateway/static/src/core/common/discuss_app_model_patch.esm.js +15 -21
  28. odoo/addons/mail_gateway/static/src/core/common/mail_composer_send_dropdown.esm.js +27 -0
  29. odoo/addons/mail_gateway/static/src/core/common/mail_composer_send_dropdown.xml +15 -0
  30. odoo/addons/mail_gateway/static/src/core/common/message_actions.esm.js +22 -20
  31. odoo/addons/mail_gateway/static/src/core/common/message_model_patch.esm.js +12 -8
  32. odoo/addons/mail_gateway/static/src/core/common/notification_model_patch.esm.js +0 -1
  33. odoo/addons/mail_gateway/static/src/core/common/persona_model_patch.esm.js +1 -3
  34. odoo/addons/mail_gateway/static/src/core/common/store_service_patch.esm.js +14 -10
  35. odoo/addons/mail_gateway/static/src/core/common/thread_model_patch.esm.js +14 -9
  36. odoo/addons/mail_gateway/static/src/core/web/discuss_app_category_model_patch.esm.js +2 -4
  37. odoo/addons/mail_gateway/static/src/core/web/discuss_sidebar_category_item_patch.xml +7 -3
  38. odoo/addons/mail_gateway/static/src/core/web/gateway_core_web_service.esm.js +13 -17
  39. odoo/addons/mail_gateway/static/src/models/gateway.esm.js +3 -4
  40. odoo/addons/mail_gateway/static/src/models/gateway_channel.esm.js +2 -3
  41. odoo/addons/mail_gateway/static/src/models/gateway_follower.esm.js +2 -3
  42. odoo/addons/mail_gateway/tools/__init__.py +1 -0
  43. odoo/addons/mail_gateway/tools/discuss.py +16 -0
  44. odoo/addons/mail_gateway/views/mail_gateway.xml +3 -3
  45. odoo/addons/mail_gateway/views/res_partner_gateway_channel.xml +3 -4
  46. odoo/addons/mail_gateway/views/res_users_settings_views.xml +12 -0
  47. odoo/addons/mail_gateway/wizards/mail_compose_gateway_message.xml +1 -5
  48. odoo/addons/mail_gateway/wizards/mail_guest_manage.xml +0 -4
  49. odoo/addons/mail_gateway/wizards/mail_message_gateway_link.py +2 -4
  50. odoo/addons/mail_gateway/wizards/mail_message_gateway_link.xml +0 -2
  51. odoo/addons/mail_gateway/wizards/mail_message_gateway_send.xml +0 -4
  52. {odoo_addon_mail_gateway-17.0.1.0.0.2.dist-info → odoo_addon_mail_gateway-18.0.1.0.0.3.dist-info}/METADATA +19 -9
  53. odoo_addon_mail_gateway-18.0.1.0.0.3.dist-info/RECORD +77 -0
  54. {odoo_addon_mail_gateway-17.0.1.0.0.2.dist-info → odoo_addon_mail_gateway-18.0.1.0.0.3.dist-info}/WHEEL +1 -1
  55. odoo/addons/mail_gateway/controllers/discuss.py +0 -11
  56. odoo/addons/mail_gateway/static/src/core/common/thread_service_patch.esm.js +0 -19
  57. odoo/addons/mail_gateway/static/src/core/web/discuss_sidebar_categories.esm.js +0 -16
  58. odoo_addon_mail_gateway-17.0.1.0.0.2.dist-info/RECORD +0 -74
  59. {odoo_addon_mail_gateway-17.0.1.0.0.2.dist-info → odoo_addon_mail_gateway-18.0.1.0.0.3.dist-info}/top_level.txt +0 -0
@@ -11,7 +11,7 @@ Mail Gateway
11
11
  !! This file is generated by oca-gen-addon-readme !!
12
12
  !! changes will be overwritten. !!
13
13
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14
- !! source digest: sha256:090c115a21a87266ff44c47592dc84c631afe5c2d4780e17abc731f918ae6c38
14
+ !! source digest: sha256:568a6781f64a53a5752bbccddcce93fffe6b683c77cb5717a30264cfab6068b9
15
15
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16
16
 
17
17
  .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -21,13 +21,13 @@ Mail Gateway
21
21
  :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
22
22
  :alt: License: AGPL-3
23
23
  .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github
24
- :target: https://github.com/OCA/social/tree/17.0/mail_gateway
24
+ :target: https://github.com/OCA/social/tree/18.0/mail_gateway
25
25
  :alt: OCA/social
26
26
  .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
27
- :target: https://translation.odoo-community.org/projects/social-17-0/social-17-0-mail_gateway
27
+ :target: https://translation.odoo-community.org/projects/social-18-0/social-18-0-mail_gateway
28
28
  :alt: Translate me on Weblate
29
29
  .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
30
- :target: https://runboat.odoo-community.org/builds?repo=OCA/social&target_branch=17.0
30
+ :target: https://runboat.odoo-community.org/builds?repo=OCA/social&target_branch=18.0
31
31
  :alt: Try me on Runboat
32
32
 
33
33
  |badge1| |badge2| |badge3| |badge4| |badge5|
@@ -62,13 +62,18 @@ the partner. To use this, we just need to use the
62
62
  It is recomended to enable chatter notification to all users that will
63
63
  receive messages from gateways.
64
64
 
65
+ Known issues / Roadmap
66
+ ======================
67
+
68
+ 1. Make possible to schedule gateway messages.
69
+
65
70
  Bug Tracker
66
71
  ===========
67
72
 
68
73
  Bugs are tracked on `GitHub Issues <https://github.com/OCA/social/issues>`_.
69
74
  In case of trouble, please check there if your issue has already been reported.
70
75
  If you spotted it first, help us to smash it by providing a detailed and welcomed
71
- `feedback <https://github.com/OCA/social/issues/new?body=module:%20mail_gateway%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
76
+ `feedback <https://github.com/OCA/social/issues/new?body=module:%20mail_gateway%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
72
77
 
73
78
  Do not contact contributors directly about support or help with technical issues.
74
79
 
@@ -85,8 +90,13 @@ Contributors
85
90
  ------------
86
91
 
87
92
  - Enric Tobella
93
+
88
94
  - Olga Marco
89
95
 
96
+ - `Tecnativa <https://tecnativa.com>`__
97
+
98
+ - Carlos Roca
99
+
90
100
  Other credits
91
101
  -------------
92
102
 
@@ -106,6 +116,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
106
116
  mission is to support the collaborative development of Odoo features and
107
117
  promote its widespread use.
108
118
 
109
- This module is part of the `OCA/social <https://github.com/OCA/social/tree/17.0/mail_gateway>`_ project on GitHub.
119
+ This module is part of the `OCA/social <https://github.com/OCA/social/tree/18.0/mail_gateway>`_ project on GitHub.
110
120
 
111
121
  You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
@@ -1,5 +1,6 @@
1
1
  from . import controllers
2
2
  from . import models
3
+ from . import tools
3
4
 
4
5
  from .hooks import pre_init_hook
5
6
  from . import wizards
@@ -4,7 +4,7 @@
4
4
  {
5
5
  "name": "Mail Gateway",
6
6
  "summary": "Base module for gateway communications",
7
- "version": "17.0.1.0.0",
7
+ "version": "18.0.1.0.0",
8
8
  "license": "AGPL-3",
9
9
  "author": "Creu Blanca,Dixmit,Odoo Community Association (OCA)",
10
10
  "website": "https://github.com/OCA/social",
@@ -20,6 +20,7 @@
20
20
  "views/mail_gateway.xml",
21
21
  "views/res_partner_gateway_channel.xml",
22
22
  "views/mail_guest_views.xml",
23
+ "views/res_users_settings_views.xml",
23
24
  ],
24
25
  "assets": {
25
26
  "web.assets_backend": [
@@ -1,2 +1 @@
1
1
  from . import gateway
2
- from . import discuss
@@ -33,7 +33,7 @@ class GatewayController(Controller):
33
33
  ],
34
34
  )
35
35
  return (
36
- request.env["mail.gateway.%s" % usage]
36
+ request.env[f"mail.gateway.{usage}"]
37
37
  .with_user(bot_data["webhook_user_id"])
38
38
  .with_company(bot_data["company_id"])
39
39
  ._receive_get_update(bot_data, request, **kwargs)
@@ -55,7 +55,7 @@ class GatewayController(Controller):
55
55
  request.httprequest.get_data().decode(request.httprequest.charset)
56
56
  )
57
57
  dispatcher = (
58
- request.env["mail.gateway.%s" % usage]
58
+ request.env[f"mail.gateway.{usage}"]
59
59
  .with_user(bot_data["webhook_user_id"])
60
60
  .with_context(no_gateway_notification=True)
61
61
  )
@@ -4,7 +4,7 @@
4
4
  #
5
5
  msgid ""
6
6
  msgstr ""
7
- "Project-Id-Version: Odoo Server 17.0\n"
7
+ "Project-Id-Version: Odoo Server 18.0\n"
8
8
  "Report-Msgid-Bugs-To: \n"
9
9
  "Last-Translator: \n"
10
10
  "Language-Team: \n"
@@ -75,11 +75,6 @@ msgstr ""
75
75
  msgid "Body content is the same as the template"
76
76
  msgstr ""
77
77
 
78
- #. module: mail_gateway
79
- #: model:ir.model.fields,field_description:mail_gateway.field_mail_compose_gateway_message__can_attach_attachment
80
- msgid "Can Attach Attachment"
81
- msgstr ""
82
-
83
78
  #. module: mail_gateway
84
79
  #: model:ir.model.fields,field_description:mail_gateway.field_mail_compose_gateway_message__can_edit_body
85
80
  msgid "Can Edit Body"
@@ -161,7 +156,6 @@ msgstr ""
161
156
  #. module: mail_gateway
162
157
  #. odoo-javascript
163
158
  #: code:addons/mail_gateway/static/src/components/message/message_patch.esm.js:0
164
- #, python-format
165
159
  msgid "Create partner"
166
160
  msgstr ""
167
161
 
@@ -205,11 +199,6 @@ msgstr ""
205
199
  msgid "Display Name"
206
200
  msgstr ""
207
201
 
208
- #. module: mail_gateway
209
- #: model:ir.model.fields,field_description:mail_gateway.field_mail_compose_gateway_message__display_object_attachment_ids
210
- msgid "Display Object Attachment"
211
- msgstr ""
212
-
213
202
  #. module: mail_gateway
214
203
  #: model:ir.model.fields,field_description:mail_gateway.field_mail_compose_gateway_message__email_layout_xmlid
215
204
  msgid "Email Notification Layout"
@@ -251,7 +240,6 @@ msgstr ""
251
240
  #: model:ir.model.fields.selection,name:mail_gateway.selection__mail_notification__notification_type__gateway
252
241
  #: model:ir.module.category,name:mail_gateway.module_category_gateway
253
242
  #: model:ir.ui.menu,name:mail_gateway.mail_gateway_menu
254
- #, python-format
255
243
  msgid "Gateway"
256
244
  msgstr ""
257
245
 
@@ -333,7 +321,6 @@ msgstr ""
333
321
  #. odoo-javascript
334
322
  #: code:addons/mail_gateway/static/src/components/chatter/chatter.xml:0
335
323
  #: code:addons/mail_gateway/static/src/components/composer/composer.esm.js:0
336
- #, python-format
337
324
  msgid "Gateway message"
338
325
  msgstr ""
339
326
 
@@ -368,13 +355,6 @@ msgstr ""
368
355
  msgid "ID"
369
356
  msgstr ""
370
357
 
371
- #. module: mail_gateway
372
- #: model:ir.model.fields,help:mail_gateway.field_mail_compose_gateway_message__mass_mailing_name
373
- msgid ""
374
- "If set, a mass mailing will be created so that you can track its results in "
375
- "the Email Marketing app."
376
- msgstr ""
377
-
378
358
  #. module: mail_gateway
379
359
  #: model:ir.model.fields,help:mail_gateway.field_mail_compose_gateway_message__scheduled_date
380
360
  msgid ""
@@ -470,7 +450,6 @@ msgstr ""
470
450
  #. module: mail_gateway
471
451
  #. odoo-javascript
472
452
  #: code:addons/mail_gateway/static/src/components/message/message_patch.esm.js:0
473
- #, python-format
474
453
  msgid "Link Message to thread"
475
454
  msgstr ""
476
455
 
@@ -482,7 +461,6 @@ msgstr ""
482
461
  #. module: mail_gateway
483
462
  #. odoo-javascript
484
463
  #: code:addons/mail_gateway/static/src/core/common/message_actions.esm.js:0
485
- #, python-format
486
464
  msgid "Link to thread"
487
465
  msgstr ""
488
466
 
@@ -511,11 +489,6 @@ msgstr ""
511
489
  msgid "Mail Message Gateway Send"
512
490
  msgstr ""
513
491
 
514
- #. module: mail_gateway
515
- #: model:ir.model.fields,field_description:mail_gateway.field_mail_compose_gateway_message__mailing_list_ids
516
- msgid "Mailing List"
517
- msgstr ""
518
-
519
492
  #. module: mail_gateway
520
493
  #: model:ir.model.fields,help:mail_gateway.field_mail_compose_gateway_message__reply_to_force_new
521
494
  msgid ""
@@ -526,25 +499,9 @@ msgstr ""
526
499
  #. module: mail_gateway
527
500
  #. odoo-javascript
528
501
  #: code:addons/mail_gateway/static/src/components/message/message_patch.esm.js:0
529
- #, python-format
530
502
  msgid "Manage guest"
531
503
  msgstr ""
532
504
 
533
- #. module: mail_gateway
534
- #: model:ir.model.fields,field_description:mail_gateway.field_mail_compose_gateway_message__mass_mailing_id
535
- msgid "Mass Mailing"
536
- msgstr ""
537
-
538
- #. module: mail_gateway
539
- #: model:ir.model.fields,field_description:mail_gateway.field_mail_compose_gateway_message__campaign_id
540
- msgid "Mass Mailing Campaign"
541
- msgstr ""
542
-
543
- #. module: mail_gateway
544
- #: model:ir.model.fields,field_description:mail_gateway.field_mail_compose_gateway_message__mass_mailing_name
545
- msgid "Mass Mailing Name"
546
- msgstr ""
547
-
548
505
  #. module: mail_gateway
549
506
  #: model:ir.model.fields,field_description:mail_gateway.field_mail_gateway__member_ids
550
507
  msgid "Member"
@@ -588,7 +545,6 @@ msgstr ""
588
545
  #. module: mail_gateway
589
546
  #. odoo-javascript
590
547
  #: code:addons/mail_gateway/static/src/components/gateway_follower/gateway_follower.xml:0
591
- #, python-format
592
548
  msgid "Not selected"
593
549
  msgstr ""
594
550
 
@@ -712,7 +668,6 @@ msgstr ""
712
668
  #. module: mail_gateway
713
669
  #. odoo-javascript
714
670
  #: code:addons/mail_gateway/static/src/core/common/discuss_app_model_patch.esm.js:0
715
- #, python-format
716
671
  msgid "Search Gateway Channel"
717
672
  msgstr ""
718
673
 
@@ -729,14 +684,12 @@ msgstr ""
729
684
  #. module: mail_gateway
730
685
  #. odoo-javascript
731
686
  #: code:addons/mail_gateway/static/src/components/composer/composer.esm.js:0
732
- #, python-format
733
687
  msgid "Send a message to a gateway..."
734
688
  msgstr ""
735
689
 
736
690
  #. module: mail_gateway
737
691
  #. odoo-javascript
738
692
  #: code:addons/mail_gateway/static/src/components/composer/composer.esm.js:0
739
- #, python-format
740
693
  msgid "Send gateway"
741
694
  msgstr ""
742
695
 
@@ -749,7 +702,6 @@ msgstr ""
749
702
  #. odoo-javascript
750
703
  #: code:addons/mail_gateway/static/src/components/message/message_patch.esm.js:0
751
704
  #: code:addons/mail_gateway/static/src/core/common/message_actions.esm.js:0
752
- #, python-format
753
705
  msgid "Send with gateway"
754
706
  msgstr ""
755
707
 
@@ -768,6 +720,11 @@ msgstr ""
768
720
  msgid "Technical data used to get the gateway author"
769
721
  msgstr ""
770
722
 
723
+ #. module: mail_gateway
724
+ #: model:ir.model.fields,field_description:mail_gateway.field_mail_compose_gateway_message__template_name
725
+ msgid "Template Name"
726
+ msgstr ""
727
+
771
728
  #. module: mail_gateway
772
729
  #: model:ir.model.fields,help:mail_gateway.field_res_users_settings__is_discuss_sidebar_category_gateway_open
773
730
  msgid "The gateway category in the sidebar will be open"
@@ -789,7 +746,6 @@ msgstr ""
789
746
  #. module: mail_gateway
790
747
  #. odoo-javascript
791
748
  #: code:addons/mail_gateway/static/src/components/chatter/chatter.xml:0
792
- #, python-format
793
749
  msgid "To:"
794
750
  msgstr ""
795
751
 
@@ -883,14 +839,12 @@ msgstr ""
883
839
  #. module: mail_gateway
884
840
  #. odoo-javascript
885
841
  #: code:addons/mail_gateway/static/src/components/chatter/chatter.xml:0
886
- #, python-format
887
842
  msgid "gateway"
888
843
  msgstr ""
889
844
 
890
845
  #. module: mail_gateway
891
846
  #. odoo-javascript
892
847
  #: code:addons/mail_gateway/static/src/components/message/message.xml:0
893
- #, python-format
894
848
  msgid "on"
895
849
  msgstr ""
896
850
 
@@ -5,6 +5,8 @@ import base64
5
5
 
6
6
  from odoo import api, fields, models
7
7
 
8
+ from odoo.addons.mail.tools.discuss import Store
9
+
8
10
 
9
11
  class MailChannel(models.Model):
10
12
  _inherit = "discuss.channel"
@@ -26,23 +28,23 @@ class MailChannel(models.Model):
26
28
  required=False,
27
29
  )
28
30
 
29
- def _compute_is_chat(self):
30
- res = super()._compute_is_chat()
31
+ def _to_store(self, store: Store):
32
+ result = super()._to_store(store)
33
+ if not self:
34
+ return result
31
35
  for record in self:
32
- if record.channel_type == "gateway":
33
- record.is_chat = True
34
- return res
35
-
36
- def _channel_info(self):
37
- result = super()._channel_info()
38
- for record, item in zip(self, result, strict=True):
39
- item["gateway"] = {
40
- "id": record.gateway_id.id,
41
- "name": record.gateway_id.name,
42
- "type": record.gateway_id.gateway_type,
43
- }
44
- item["gateway_name"] = record.gateway_id.name
45
- item["gateway_id"] = record.gateway_id.id
36
+ store.add(
37
+ record,
38
+ {
39
+ "gateway": {
40
+ "id": record.gateway_id.id,
41
+ "name": record.gateway_id.name,
42
+ "type": record.gateway_id.gateway_type,
43
+ },
44
+ "gateway_name": record.gateway_id.name,
45
+ "gateway_id": record.gateway_id.id,
46
+ },
47
+ )
46
48
  return result
47
49
 
48
50
  def _generate_avatar_gateway(self):
@@ -58,9 +60,13 @@ class MailChannel(models.Model):
58
60
  return base64.b64encode(avatar.encode())
59
61
 
60
62
  @api.returns("mail.message", lambda value: value.id)
61
- def message_post(self, *args, gateway_type=False, **kwargs):
63
+ def message_post(
64
+ self, *, message_type="notification", gateway_type=False, **kwargs
65
+ ):
62
66
  message = super().message_post(
63
- *args, gateway_type=gateway_type or self.gateway_id.gateway_type, **kwargs
67
+ message_type=message_type,
68
+ gateway_type=gateway_type or self.gateway_id.gateway_type,
69
+ **kwargs,
64
70
  )
65
71
  if (
66
72
  self.gateway_id
@@ -79,11 +79,11 @@ class MailGateway(models.Model):
79
79
  def set_webhook(self):
80
80
  self.ensure_one()
81
81
  if self.can_set_webhook:
82
- self.env["mail.gateway.%s" % self.gateway_type]._set_webhook(self)
82
+ self.env[f"mail.gateway.{self.gateway_type}"]._set_webhook(self)
83
83
 
84
84
  def remove_webhook(self):
85
85
  self.ensure_one()
86
- self.env["mail.gateway.%s" % self.gateway_type]._remove_webhook(self)
86
+ self.env[f"mail.gateway.{self.gateway_type}"]._remove_webhook(self)
87
87
 
88
88
  def update_webhook(self):
89
89
  self.ensure_one()
@@ -98,13 +98,13 @@ class MailGateway(models.Model):
98
98
  or "webhook_secret" in vals
99
99
  or "webhook_user_id" in vals
100
100
  ):
101
- self.clear_caches()
101
+ self.env.registry.clear_cache()
102
102
  return res
103
103
 
104
104
  @api.model_create_multi
105
105
  def create(self, mvals):
106
106
  res = super().create(mvals)
107
- self.clear_caches()
107
+ self.env.registry.clear_cache()
108
108
  return res
109
109
 
110
110
  @api.model
@@ -48,7 +48,7 @@ class MailGatewayAbstract(models.AbstractModel):
48
48
  def _get_channel_vals(self, gateway, token, update):
49
49
  author = self._get_author(gateway, update)
50
50
  members = [
51
- Command.create({"partner_id": partner.id, "is_pinned": True})
51
+ Command.create({"partner_id": partner.id, "unpin_dt": False})
52
52
  for partner in gateway.member_ids.partner_id
53
53
  ]
54
54
  if author:
@@ -3,6 +3,8 @@
3
3
 
4
4
  from odoo import fields, models
5
5
 
6
+ from odoo.addons.mail.tools.discuss import Store
7
+
6
8
 
7
9
  class MailGuest(models.Model):
8
10
  _inherit = "mail.guest"
@@ -10,9 +12,9 @@ class MailGuest(models.Model):
10
12
  gateway_id = fields.Many2one("mail.gateway")
11
13
  gateway_token = fields.Char()
12
14
 
13
- def _guest_format(self, fields=None):
14
- result = super()._guest_format(fields=fields)
15
+ def _to_store(self, store: Store, /, *, fields=None):
16
+ result = super()._to_store(store, fields=fields)
15
17
  if not fields or "gateway_id" in fields:
16
- for guest in result:
17
- result[guest]["gateway"] = {"id": guest.gateway_id.id}
18
+ for record in self:
19
+ store.add(record, {"gateway": {"id": record.gateway_id.id}})
18
20
  return result
@@ -4,6 +4,8 @@
4
4
 
5
5
  from odoo import api, fields, models
6
6
 
7
+ from odoo.addons.mail.tools.discuss import Store
8
+
7
9
 
8
10
  class MailMessage(models.Model):
9
11
  _inherit = "mail.message"
@@ -78,9 +80,36 @@ class MailMessage(models.Model):
78
80
  0
79
81
  ].gateway_channel_id
80
82
 
81
- def _get_message_format_fields(self):
82
- result = super()._get_message_format_fields()
83
- result += ["gateway_type", "gateway_channel_data", "gateway_thread_data"]
83
+ def _to_store(
84
+ self,
85
+ store: Store,
86
+ /,
87
+ *,
88
+ fields=None,
89
+ format_reply=True,
90
+ msg_vals=None,
91
+ for_current_user=False,
92
+ add_followers=False,
93
+ followers=None,
94
+ ):
95
+ result = super()._to_store(
96
+ store,
97
+ fields=fields,
98
+ format_reply=format_reply,
99
+ msg_vals=msg_vals,
100
+ for_current_user=for_current_user,
101
+ add_followers=add_followers,
102
+ followers=followers,
103
+ )
104
+ for record in self:
105
+ store.add(
106
+ record,
107
+ {
108
+ "gateway_type": record.gateway_type,
109
+ "gateway_channel_data": record.gateway_channel_data,
110
+ "gateway_thread_data": record.gateway_thread_data,
111
+ },
112
+ )
84
113
  return result
85
114
 
86
115
  def _send_to_gateway_thread(self, gateway_channel_id):
@@ -100,17 +129,6 @@ class MailMessage(models.Model):
100
129
  "gateway_type": gateway_channel_id.gateway_id.gateway_type,
101
130
  }
102
131
  )
103
- self.env["bus.bus"]._sendone(
104
- self.env.user.partner_id,
105
- "mail.message/insert",
106
- {
107
- "id": self.id,
108
- "gateway_type": self.gateway_type,
109
- "notifications": self.sudo()
110
- .notification_ids._filtered_for_web_client()
111
- ._notification_format(),
112
- },
113
- )
114
132
  return {}
115
133
 
116
134
  def _get_gateway_thread_message_vals(self):
@@ -3,6 +3,8 @@
3
3
 
4
4
  from odoo import fields, models
5
5
 
6
+ from odoo.addons.mail.tools.discuss import Store
7
+
6
8
 
7
9
  class MailNotification(models.Model):
8
10
  _inherit = "mail.notification"
@@ -24,17 +26,22 @@ class MailNotification(models.Model):
24
26
  def _set_read_gateway(self):
25
27
  self.sudo().write({"is_read": True, "read_date": fields.Datetime.now()})
26
28
 
27
- def _notification_format(self):
28
- result = super()._notification_format()
29
- for record, formatted_value in zip(self, result, strict=True):
30
- formatted_value["gateway_type"] = record.gateway_type
31
- formatted_value["channel_name"] = record.gateway_channel_id.name
29
+ def _to_store(self, store: Store, /):
30
+ result = super()._to_store(store)
31
+ for record in self:
32
+ store.add(
33
+ record,
34
+ {
35
+ "gateway_type": record.gateway_type,
36
+ "channel_name": record.gateway_channel_id.name,
37
+ },
38
+ )
32
39
  return result
33
40
 
34
41
  def send_gateway(self, auto_commit=False, raise_exception=False, parse_mode="HTML"):
35
42
  for record in self:
36
43
  gateway = record.gateway_channel_id.gateway_id
37
- self.env["mail.gateway.%s" % gateway.gateway_type]._send(
44
+ self.env[f"mail.gateway.{gateway.gateway_type}"]._send(
38
45
  gateway,
39
46
  record,
40
47
  auto_commit=auto_commit,
@@ -2,6 +2,8 @@
2
2
  # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3
3
  from odoo import models
4
4
 
5
+ from odoo.addons.mail.tools.discuss import Store
6
+
5
7
 
6
8
  class MailThread(models.AbstractModel):
7
9
  _inherit = "mail.thread"
@@ -68,14 +70,23 @@ class MailThread(models.AbstractModel):
68
70
  return result
69
71
  return super()._notify_get_recipients(message, msg_vals, **kwargs)
70
72
 
71
- def _get_mail_thread_data(self, request_list):
72
- data = super()._get_mail_thread_data(request_list)
73
- data["gateway_followers"] = [
74
- f["partner"]
75
- for f in data.get("followers", [])
76
- if f["partner"]["gateway_channels"]
77
- ]
78
- return data
73
+ def _thread_to_store(self, store: Store, /, *, fields=None, request_list=None):
74
+ res = super()._thread_to_store(store, fields=fields, request_list=request_list)
75
+ for record in self:
76
+ followers = record.message_get_followers()
77
+ if "mail.followers" in followers:
78
+ store.add(
79
+ record,
80
+ {
81
+ "gateway_followers": [
82
+ f["partner"]
83
+ for f in followers["mail.followers"]
84
+ if f["partner"]["gateway_channels"]
85
+ ]
86
+ },
87
+ as_thread=True,
88
+ )
89
+ return res
79
90
 
80
91
  def _check_can_update_message_content(self, messages):
81
92
  # We can delete the messages comming from a gateway on not channels
@@ -106,12 +117,15 @@ class MailThread(models.AbstractModel):
106
117
  # Unlink the message
107
118
  for gateway_msg in message.gateway_message_ids:
108
119
  gateway_msg.gateway_message_id = False
109
- self.env["bus.bus"]._sendone(
110
- self.env.user.partner_id,
111
- "mail.message/insert",
120
+ gateway_msg._bus_send_store(
121
+ gateway_msg,
112
122
  {
113
- "id": gateway_msg.id,
114
123
  "gateway_thread_data": gateway_msg.sudo().gateway_thread_data,
115
124
  },
116
125
  )
117
126
  return result
127
+
128
+ def _get_allowed_message_post_params(self):
129
+ result = super()._get_allowed_message_post_params()
130
+ result.add("gateway_notifications")
131
+ return result
@@ -13,20 +13,6 @@ class ResPartner(models.Model):
13
13
  "res.partner.gateway.channel", inverse_name="partner_id"
14
14
  )
15
15
 
16
- def mail_partner_format(self, fields=None):
17
- """Override to add gateway info."""
18
- partners_format = super().mail_partner_format(fields=fields)
19
- if not fields:
20
- fields = {"gateway_channel_ids": True}
21
- for partner in self:
22
- if "gateway_channel_ids" in fields:
23
- partners_format.get(partner).update(
24
- {
25
- "gateway_channels": partner.gateway_channel_ids.mail_format(),
26
- }
27
- )
28
- return partners_format
29
-
30
16
  def _get_channels_as_member(self):
31
17
  channels = super()._get_channels_as_member()
32
18
  if self.env.user.has_group("mail_gateway.gateway_user"):
@@ -9,7 +9,7 @@ class ResUsers(models.Model):
9
9
 
10
10
  gateway_ids = fields.Many2many("mail.gateway")
11
11
 
12
- def _init_messaging(self):
13
- result = super()._init_messaging()
14
- result["gateways"] = self.gateway_ids.gateway_info()
12
+ def _init_messaging(self, store):
13
+ result = super()._init_messaging(store)
14
+ store.add({"gateways": self.gateway_ids.gateway_info()})
15
15
  return result
@@ -1,2 +1,5 @@
1
1
  - Enric Tobella
2
2
  - Olga Marco
3
+
4
+ - [Tecnativa](https://tecnativa.com)
5
+ - Carlos Roca
@@ -0,0 +1 @@
1
+ 1. Make possible to schedule gateway messages.
@@ -57,5 +57,4 @@
57
57
  <field name="perm_create" eval="False" />
58
58
  <field name="perm_unlink" eval="True" />
59
59
  </record>
60
-
61
60
  </odoo>