odoo-addon-mail-gateway 16.0.1.3.0__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.
- odoo/addons/mail_gateway/README.rst +41 -24
- odoo/addons/mail_gateway/__init__.py +1 -1
- odoo/addons/mail_gateway/__manifest__.py +7 -14
- odoo/addons/mail_gateway/controllers/__init__.py +0 -1
- odoo/addons/mail_gateway/controllers/gateway.py +5 -2
- odoo/addons/mail_gateway/hooks.py +3 -3
- odoo/addons/mail_gateway/i18n/es.po +68 -406
- odoo/addons/mail_gateway/i18n/it.po +5 -336
- odoo/addons/mail_gateway/i18n/mail_gateway.pot +140 -121
- odoo/addons/mail_gateway/models/__init__.py +4 -3
- odoo/addons/mail_gateway/models/{mail_channel.py → discuss_channel.py} +45 -17
- odoo/addons/mail_gateway/models/ir_websocket.py +1 -1
- odoo/addons/mail_gateway/models/mail_gateway.py +8 -8
- odoo/addons/mail_gateway/models/mail_gateway_abstract.py +3 -3
- odoo/addons/mail_gateway/models/mail_guest.py +6 -4
- odoo/addons/mail_gateway/models/mail_message.py +40 -21
- odoo/addons/mail_gateway/models/mail_notification.py +15 -8
- odoo/addons/mail_gateway/models/mail_thread.py +56 -10
- odoo/addons/mail_gateway/models/res_partner.py +10 -32
- odoo/addons/mail_gateway/models/res_users.py +3 -4
- odoo/addons/mail_gateway/models/res_users_settings.py +12 -0
- odoo/addons/mail_gateway/readme/CONTRIBUTORS.md +5 -0
- odoo/addons/mail_gateway/readme/{CREDITS.rst → CREDITS.md} +2 -1
- odoo/addons/mail_gateway/readme/DESCRIPTION.md +8 -0
- odoo/addons/mail_gateway/readme/ROADMAP.md +1 -0
- odoo/addons/mail_gateway/readme/USAGE.md +12 -0
- odoo/addons/mail_gateway/security/ir.model.access.csv +4 -2
- odoo/addons/mail_gateway/security/security.xml +9 -10
- odoo/addons/mail_gateway/static/description/index.html +46 -28
- odoo/addons/mail_gateway/static/src/components/chatter/chatter.esm.js +14 -0
- odoo/addons/mail_gateway/static/src/components/chatter/chatter.xml +42 -22
- odoo/addons/mail_gateway/static/src/components/composer/composer.esm.js +107 -0
- odoo/addons/mail_gateway/static/src/components/gateway_follower/gateway_follower.esm.js +35 -23
- odoo/addons/mail_gateway/static/src/components/gateway_follower/gateway_follower.xml +3 -5
- odoo/addons/mail_gateway/static/src/components/message/message.xml +15 -15
- odoo/addons/mail_gateway/static/src/components/message/message_patch.esm.js +67 -0
- odoo/addons/mail_gateway/static/src/components/message_notification_popover_content/message_notification_popover_content.xml +3 -7
- odoo/addons/mail_gateway/static/src/core/common/composer_model_patch.esm.js +22 -0
- odoo/addons/mail_gateway/static/src/core/common/discuss_app_model_patch.esm.js +25 -0
- odoo/addons/mail_gateway/static/src/core/common/mail_composer_send_dropdown.esm.js +27 -0
- odoo/addons/mail_gateway/static/src/core/common/mail_composer_send_dropdown.xml +15 -0
- odoo/addons/mail_gateway/static/src/core/common/message_actions.esm.js +25 -0
- odoo/addons/mail_gateway/static/src/core/common/message_model_patch.esm.js +25 -0
- odoo/addons/mail_gateway/static/src/core/common/notification_model_patch.esm.js +34 -0
- odoo/addons/mail_gateway/static/src/core/common/persona_model_patch.esm.js +10 -0
- odoo/addons/mail_gateway/static/src/core/common/store_service_patch.esm.js +18 -0
- odoo/addons/mail_gateway/static/src/core/common/thread_model_patch.esm.js +54 -0
- odoo/addons/mail_gateway/static/src/core/web/discuss_app_category_model_patch.esm.js +19 -0
- odoo/addons/mail_gateway/static/src/core/web/discuss_sidebar_category_item_patch.xml +16 -0
- odoo/addons/mail_gateway/static/src/core/web/gateway_core_web_service.esm.js +36 -0
- odoo/addons/mail_gateway/static/src/models/gateway.esm.js +21 -15
- odoo/addons/mail_gateway/static/src/models/gateway_channel.esm.js +20 -13
- odoo/addons/mail_gateway/static/src/models/gateway_follower.esm.js +23 -0
- odoo/addons/mail_gateway/tools/__init__.py +1 -0
- odoo/addons/mail_gateway/tools/discuss.py +16 -0
- odoo/addons/mail_gateway/views/mail_gateway.xml +7 -7
- odoo/addons/mail_gateway/views/mail_guest_views.xml +15 -0
- odoo/addons/mail_gateway/views/res_partner_gateway_channel.xml +3 -4
- odoo/addons/mail_gateway/views/res_users_settings_views.xml +12 -0
- odoo/addons/mail_gateway/wizards/mail_compose_gateway_message.py +19 -4
- odoo/addons/mail_gateway/wizards/mail_compose_gateway_message.xml +2 -7
- odoo/addons/mail_gateway/wizards/mail_guest_manage.py +2 -3
- odoo/addons/mail_gateway/wizards/mail_guest_manage.xml +2 -6
- odoo/addons/mail_gateway/wizards/mail_message_gateway_link.py +3 -6
- odoo/addons/mail_gateway/wizards/mail_message_gateway_link.xml +0 -2
- odoo/addons/mail_gateway/wizards/mail_message_gateway_send.py +0 -1
- odoo/addons/mail_gateway/wizards/mail_message_gateway_send.xml +0 -4
- {odoo_addon_mail_gateway-16.0.1.3.0.dist-info → odoo_addon_mail_gateway-18.0.1.0.0.3.dist-info}/METADATA +48 -30
- odoo_addon_mail_gateway-18.0.1.0.0.3.dist-info/RECORD +77 -0
- {odoo_addon_mail_gateway-16.0.1.3.0.dist-info → odoo_addon_mail_gateway-18.0.1.0.0.3.dist-info}/WHEEL +1 -1
- odoo_addon_mail_gateway-18.0.1.0.0.3.dist-info/top_level.txt +1 -0
- odoo/addons/mail_gateway/controllers/discuss.py +0 -11
- odoo/addons/mail_gateway/i18n/es_VE.po +0 -879
- odoo/addons/mail_gateway/readme/CONTRIBUTORS.rst +0 -2
- odoo/addons/mail_gateway/readme/DESCRIPTION.rst +0 -5
- odoo/addons/mail_gateway/readme/USAGE.rst +0 -9
- odoo/addons/mail_gateway/static/src/components/composer/composer.xml +0 -24
- odoo/addons/mail_gateway/static/src/components/discuss_sidebar/discuss_sidebar.xml +0 -17
- odoo/addons/mail_gateway/static/src/models/channel.esm.js +0 -33
- odoo/addons/mail_gateway/static/src/models/channel_member_view.esm.js +0 -39
- odoo/addons/mail_gateway/static/src/models/chatter.esm.js +0 -41
- odoo/addons/mail_gateway/static/src/models/composer.esm.js +0 -32
- odoo/addons/mail_gateway/static/src/models/composer_gateway_follower.esm.js +0 -32
- odoo/addons/mail_gateway/static/src/models/composer_view.esm.js +0 -103
- odoo/addons/mail_gateway/static/src/models/discuss.esm.js +0 -51
- odoo/addons/mail_gateway/static/src/models/discuss_sidebar_category.esm.js +0 -128
- odoo/addons/mail_gateway/static/src/models/discuss_sidebar_category_item.esm.js +0 -51
- odoo/addons/mail_gateway/static/src/models/gateway_channel_view.esm.js +0 -15
- odoo/addons/mail_gateway/static/src/models/guest.esm.js +0 -10
- odoo/addons/mail_gateway/static/src/models/message.esm.js +0 -76
- odoo/addons/mail_gateway/static/src/models/message_action.esm.js +0 -45
- odoo/addons/mail_gateway/static/src/models/message_action_list.esm.js +0 -37
- odoo/addons/mail_gateway/static/src/models/message_action_view.esm.js +0 -91
- odoo/addons/mail_gateway/static/src/models/message_view.esm.js +0 -13
- odoo/addons/mail_gateway/static/src/models/messaging_initializer.esm.js +0 -24
- odoo/addons/mail_gateway/static/src/models/notification.esm.js +0 -20
- odoo/addons/mail_gateway/static/src/models/partner.esm.js +0 -11
- odoo/addons/mail_gateway/static/src/models/thread.esm.js +0 -77
- odoo_addon_mail_gateway-16.0.1.3.0.dist-info/RECORD +0 -78
- odoo_addon_mail_gateway-16.0.1.3.0.dist-info/top_level.txt +0 -1
|
@@ -49,7 +49,7 @@ class MailGateway(models.Model):
|
|
|
49
49
|
|
|
50
50
|
def _get_channel_id(self, chat_token):
|
|
51
51
|
return (
|
|
52
|
-
self.env["
|
|
52
|
+
self.env["discuss.channel"]
|
|
53
53
|
.search(
|
|
54
54
|
[
|
|
55
55
|
("gateway_channel_token", "=", str(chat_token)),
|
|
@@ -61,7 +61,7 @@ class MailGateway(models.Model):
|
|
|
61
61
|
)
|
|
62
62
|
|
|
63
63
|
def _get_webhook_url(self):
|
|
64
|
-
return "
|
|
64
|
+
return "{}/gateway/{}/{}/update".format(
|
|
65
65
|
self.webhook_url
|
|
66
66
|
or self.env["ir.config_parameter"].get_param("web.base.url"),
|
|
67
67
|
self.gateway_type,
|
|
@@ -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
|
|
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
|
|
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()
|
|
@@ -91,20 +91,20 @@ class MailGateway(models.Model):
|
|
|
91
91
|
self.set_webhook()
|
|
92
92
|
|
|
93
93
|
def write(self, vals):
|
|
94
|
-
res = super(
|
|
94
|
+
res = super().write(vals)
|
|
95
95
|
if (
|
|
96
96
|
"webhook_key" in vals
|
|
97
97
|
or "integrated_webhook_state" in vals
|
|
98
98
|
or "webhook_secret" in vals
|
|
99
99
|
or "webhook_user_id" in vals
|
|
100
100
|
):
|
|
101
|
-
self.
|
|
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
|
-
res = super(
|
|
107
|
-
self.
|
|
106
|
+
res = super().create(mvals)
|
|
107
|
+
self.env.registry.clear_cache()
|
|
108
108
|
return res
|
|
109
109
|
|
|
110
110
|
@api.model
|
|
@@ -33,10 +33,10 @@ class MailGatewayAbstract(models.AbstractModel):
|
|
|
33
33
|
def _get_channel(self, gateway, token, update, force_create=False):
|
|
34
34
|
chat_id = gateway._get_channel_id(token)
|
|
35
35
|
if chat_id:
|
|
36
|
-
return gateway.env["
|
|
36
|
+
return gateway.env["discuss.channel"].browse(chat_id)
|
|
37
37
|
if not force_create and gateway.has_new_channel_security:
|
|
38
38
|
return False
|
|
39
|
-
channel = gateway.env["
|
|
39
|
+
channel = gateway.env["discuss.channel"].create(
|
|
40
40
|
self._get_channel_vals(gateway, token, update)
|
|
41
41
|
)
|
|
42
42
|
channel._broadcast(channel.channel_member_ids.mapped("partner_id").ids)
|
|
@@ -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, "
|
|
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
|
|
14
|
-
result = super().
|
|
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
|
|
17
|
-
|
|
18
|
+
for record in self:
|
|
19
|
+
store.add(record, {"gateway": {"id": record.gateway_id.id}})
|
|
18
20
|
return result
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
from odoo import api, fields, models
|
|
6
6
|
|
|
7
|
+
from odoo.addons.mail.tools.discuss import Store
|
|
7
8
|
|
|
8
|
-
class MailMessage(models.Model):
|
|
9
9
|
|
|
10
|
+
class MailMessage(models.Model):
|
|
10
11
|
_inherit = "mail.message"
|
|
11
12
|
|
|
12
13
|
gateway_type = fields.Selection(
|
|
@@ -49,14 +50,18 @@ class MailMessage(models.Model):
|
|
|
49
50
|
def _compute_gateway_channel_ids(self):
|
|
50
51
|
for record in self:
|
|
51
52
|
if self.env.user.has_group("mail_gateway.gateway_user"):
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
partners = record.notification_ids.res_partner_id
|
|
54
|
+
channels = partners.gateway_channel_ids.filtered(
|
|
55
|
+
lambda r, messages=record.gateway_message_ids: (
|
|
56
|
+
r.gateway_token,
|
|
57
|
+
r.gateway_id.id,
|
|
58
|
+
)
|
|
54
59
|
not in [
|
|
55
60
|
(
|
|
56
61
|
notification.gateway_channel_id.gateway_channel_token,
|
|
57
62
|
notification.gateway_channel_id.gateway_id.id,
|
|
58
63
|
)
|
|
59
|
-
for notification in
|
|
64
|
+
for notification in messages.gateway_notification_ids
|
|
60
65
|
]
|
|
61
66
|
)
|
|
62
67
|
else:
|
|
@@ -75,18 +80,43 @@ class MailMessage(models.Model):
|
|
|
75
80
|
0
|
|
76
81
|
].gateway_channel_id
|
|
77
82
|
|
|
78
|
-
def
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
+
)
|
|
83
113
|
return result
|
|
84
114
|
|
|
85
115
|
def _send_to_gateway_thread(self, gateway_channel_id):
|
|
86
116
|
chat_id = gateway_channel_id.gateway_id._get_channel_id(
|
|
87
117
|
gateway_channel_id.gateway_token
|
|
88
118
|
)
|
|
89
|
-
channel = self.env["
|
|
119
|
+
channel = self.env["discuss.channel"].browse(chat_id)
|
|
90
120
|
channel.message_post(**self._get_gateway_thread_message_vals())
|
|
91
121
|
if not self.gateway_type:
|
|
92
122
|
self.gateway_type = gateway_channel_id.gateway_id.gateway_type
|
|
@@ -99,17 +129,6 @@ class MailMessage(models.Model):
|
|
|
99
129
|
"gateway_type": gateway_channel_id.gateway_id.gateway_type,
|
|
100
130
|
}
|
|
101
131
|
)
|
|
102
|
-
self.env["bus.bus"]._sendone(
|
|
103
|
-
self.env.user.partner_id,
|
|
104
|
-
"mail.message/insert",
|
|
105
|
-
{
|
|
106
|
-
"id": self.id,
|
|
107
|
-
"gateway_type": self.gateway_type,
|
|
108
|
-
"notifications": self.sudo()
|
|
109
|
-
.notification_ids._filtered_for_web_client()
|
|
110
|
-
._notification_format(),
|
|
111
|
-
},
|
|
112
|
-
)
|
|
113
132
|
return {}
|
|
114
133
|
|
|
115
134
|
def _get_gateway_thread_message_vals(self):
|
|
@@ -3,17 +3,19 @@
|
|
|
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"
|
|
9
11
|
|
|
10
|
-
gateway_channel_id = fields.Many2one("
|
|
12
|
+
gateway_channel_id = fields.Many2one("discuss.channel")
|
|
11
13
|
notification_type = fields.Selection(
|
|
12
14
|
selection_add=[("gateway", "Gateway")], ondelete={"gateway": "cascade"}
|
|
13
15
|
)
|
|
14
16
|
gateway_message_id = fields.Char(readonly=True)
|
|
15
17
|
gateway_failure_reason = fields.Text(
|
|
16
|
-
readonly=
|
|
18
|
+
readonly=True,
|
|
17
19
|
help="Failure reason. This is usually the exception thrown by the"
|
|
18
20
|
" email server, stored to ease the debugging of mailing issues.",
|
|
19
21
|
)
|
|
@@ -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
|
|
28
|
-
result = super().
|
|
29
|
-
for record
|
|
30
|
-
|
|
31
|
-
|
|
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
|
|
44
|
+
self.env[f"mail.gateway.{gateway.gateway_type}"]._send(
|
|
38
45
|
gateway,
|
|
39
46
|
record,
|
|
40
47
|
auto_commit=auto_commit,
|
|
@@ -2,10 +2,24 @@
|
|
|
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"
|
|
8
10
|
|
|
11
|
+
def _get_message_create_valid_field_names(self):
|
|
12
|
+
# Add gateway fields
|
|
13
|
+
field_names = super()._get_message_create_valid_field_names()
|
|
14
|
+
field_names.update(
|
|
15
|
+
{"gateway_type", "gateway_notifications", "gateway_message_id"}
|
|
16
|
+
)
|
|
17
|
+
return field_names
|
|
18
|
+
|
|
19
|
+
def _get_notify_valid_parameters(self):
|
|
20
|
+
notify_valid_parameters = super()._get_notify_valid_parameters()
|
|
21
|
+
return notify_valid_parameters | {"gateway_notifications"}
|
|
22
|
+
|
|
9
23
|
def _notify_thread_by_email(self, message, recipients_data, **kwargs):
|
|
10
24
|
partners_data = [r for r in recipients_data if r["notif"] == "gateway"]
|
|
11
25
|
if partners_data:
|
|
@@ -56,30 +70,62 @@ class MailThread(models.AbstractModel):
|
|
|
56
70
|
return result
|
|
57
71
|
return super()._notify_get_recipients(message, msg_vals, **kwargs)
|
|
58
72
|
|
|
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
|
|
90
|
+
|
|
59
91
|
def _check_can_update_message_content(self, messages):
|
|
60
92
|
# We can delete the messages comming from a gateway on not channels
|
|
61
|
-
if self._name != "
|
|
93
|
+
if self._name != "discuss.channel":
|
|
62
94
|
new_messages = messages.filtered(lambda r: not r.gateway_message_ids)
|
|
63
95
|
else:
|
|
64
96
|
new_messages = messages
|
|
65
97
|
return super()._check_can_update_message_content(new_messages)
|
|
66
98
|
|
|
67
99
|
def _message_update_content(
|
|
68
|
-
self,
|
|
100
|
+
self,
|
|
101
|
+
message,
|
|
102
|
+
body,
|
|
103
|
+
attachment_ids=None,
|
|
104
|
+
partner_ids=None,
|
|
105
|
+
strict=True,
|
|
106
|
+
**kwargs,
|
|
69
107
|
):
|
|
70
108
|
result = super()._message_update_content(
|
|
71
|
-
message
|
|
109
|
+
message=message,
|
|
110
|
+
body=body,
|
|
111
|
+
attachment_ids=attachment_ids,
|
|
112
|
+
partner_ids=partner_ids,
|
|
113
|
+
strict=strict,
|
|
114
|
+
**kwargs,
|
|
72
115
|
)
|
|
73
116
|
if body == "":
|
|
74
117
|
# Unlink the message
|
|
75
|
-
for
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"mail.message/insert",
|
|
118
|
+
for gateway_msg in message.gateway_message_ids:
|
|
119
|
+
gateway_msg.gateway_message_id = False
|
|
120
|
+
gateway_msg._bus_send_store(
|
|
121
|
+
gateway_msg,
|
|
80
122
|
{
|
|
81
|
-
"
|
|
82
|
-
"gateway_thread_data": gateway_message.sudo().gateway_thread_data,
|
|
123
|
+
"gateway_thread_data": gateway_msg.sudo().gateway_thread_data,
|
|
83
124
|
},
|
|
84
125
|
)
|
|
85
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
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Copyright 2024 Dixmit
|
|
2
2
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
3
3
|
|
|
4
|
-
from odoo import fields, models
|
|
4
|
+
from odoo import api, fields, models
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class ResPartner(models.Model):
|
|
@@ -13,30 +13,16 @@ 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"):
|
|
33
|
-
channels |= self.env["
|
|
19
|
+
channels |= self.env["discuss.channel"].search(
|
|
34
20
|
[
|
|
35
21
|
("channel_type", "=", "gateway"),
|
|
36
22
|
(
|
|
37
23
|
"channel_member_ids",
|
|
38
24
|
"in",
|
|
39
|
-
self.env["
|
|
25
|
+
self.env["discuss.channel.member"]
|
|
40
26
|
.sudo()
|
|
41
27
|
._search(
|
|
42
28
|
[
|
|
@@ -66,24 +52,16 @@ class ResPartnerGatewayChannel(models.Model):
|
|
|
66
52
|
"res.company", related="gateway_id.company_id", store=True
|
|
67
53
|
)
|
|
68
54
|
|
|
69
|
-
|
|
55
|
+
@api.depends_context("mail_gateway_partner_info")
|
|
56
|
+
def _compute_display_name(self):
|
|
70
57
|
# Be able to tell to which partner belongs the gateway partner channel
|
|
71
58
|
# e.g.: picking it from a selector
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
for record in self:
|
|
78
|
-
result.append(
|
|
79
|
-
(
|
|
80
|
-
record.id,
|
|
81
|
-
"{} ({})".format(
|
|
82
|
-
record.partner_id.display_name, origin_dict[record.id]
|
|
83
|
-
),
|
|
84
|
-
)
|
|
59
|
+
if not self.env.context.get("mail_gateway_partner_info"):
|
|
60
|
+
return super()._compute_display_name()
|
|
61
|
+
for gateway_channel in self:
|
|
62
|
+
gateway_channel.display_name = (
|
|
63
|
+
f"{gateway_channel.partner_id.display_name} ({gateway_channel.name})"
|
|
85
64
|
)
|
|
86
|
-
return result
|
|
87
65
|
|
|
88
66
|
_sql_constraints = [
|
|
89
67
|
(
|
|
@@ -5,12 +5,11 @@ from odoo import fields, models
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class ResUsers(models.Model):
|
|
8
|
-
|
|
9
8
|
_inherit = "res.users"
|
|
10
9
|
|
|
11
10
|
gateway_ids = fields.Many2many("mail.gateway")
|
|
12
11
|
|
|
13
|
-
def _init_messaging(self):
|
|
14
|
-
result = super()._init_messaging()
|
|
15
|
-
|
|
12
|
+
def _init_messaging(self, store):
|
|
13
|
+
result = super()._init_messaging(store)
|
|
14
|
+
store.add({"gateways": self.gateway_ids.gateway_info()})
|
|
16
15
|
return result
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
|
2
|
+
from odoo import fields, models
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ResUsersSettings(models.Model):
|
|
6
|
+
_inherit = "res.users.settings"
|
|
7
|
+
|
|
8
|
+
is_discuss_sidebar_category_gateway_open = fields.Boolean(
|
|
9
|
+
string="Gateway Category Open",
|
|
10
|
+
default=True,
|
|
11
|
+
help="The gateway category in the sidebar will be open",
|
|
12
|
+
)
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
This work has been funded by AEOdoo (Asociación Española de Odoo -
|
|
1
|
+
This work has been funded by AEOdoo (Asociación Española de Odoo -
|
|
2
|
+
<https://www.aeodoo.org>)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
This module will allow you to integrate an external chat system in your
|
|
2
|
+
Odoo system. It requires extra modules with the specific configuration
|
|
3
|
+
of each chat system, like mail_gateway_telegram or
|
|
4
|
+
mail_gateway_whatsapp.
|
|
5
|
+
|
|
6
|
+
This way, a group of users can respond customers or any other set of
|
|
7
|
+
partners within Odoo, but the messages will be sent through the external
|
|
8
|
+
chat system.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1. Make possible to schedule gateway messages.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
When external messages are received, they will be directly sent to the
|
|
2
|
+
discuss menu. Answering to these messages will send the answer to the
|
|
3
|
+
external contact. We can assign this messages to any record using the
|
|
4
|
+
message actions. Also, we can assign the sender to a partner using the
|
|
5
|
+
followers menu and selecting the partner.
|
|
6
|
+
|
|
7
|
+
On a standard record associated to a partner with external chat, we can
|
|
8
|
+
send messages to the external contact directly selecting the methods of
|
|
9
|
+
the partner. To use this, we just need to use the
|
|
10
|
+
|
|
11
|
+
It is recomended to enable chatter notification to all users that will
|
|
12
|
+
receive messages from gateways.
|
|
@@ -3,8 +3,10 @@ access_res_partner_gateway_channel_portal,res.partner.gateway.channel.portal,mod
|
|
|
3
3
|
access_res_partner_gateway_channel_user,res.partner.gateway.channel,model_res_partner_gateway_channel,base.group_user,1,0,0,0
|
|
4
4
|
manage_res_partner_gateway_channel_user,res.partner.gateway.channel,model_res_partner_gateway_channel,gateway_user,1,1,1,1
|
|
5
5
|
access_mail_message_gateway_send_user,mail.message.gateway.send,model_mail_message_gateway_send,base.group_user,1,1,1,0
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
access_mail_gateway_portal,mail.gateway.portal,model_mail_gateway,base.group_portal,1,0,0,0
|
|
7
|
+
access_mail_gateway_public,mail.gateway.public,model_mail_gateway,base.group_public,1,0,0,0
|
|
8
|
+
access_mail_gateway_user,mail.gateway.user,model_mail_gateway,base.group_user,1,0,0,0
|
|
9
|
+
access_mail_guest_manage,mail.gateway.internal,model_mail_guest_manage,base.group_user,1,1,1,1
|
|
8
10
|
access_mail_message_gateway_link,mail.message.link.all,model_mail_message_gateway_link,base.group_user,1,1,1,1
|
|
9
11
|
access_mail_gateway_system,mail_gateway,model_mail_gateway,base.group_system,1,1,1,1
|
|
10
12
|
access_mail_compose_gateway_message,access.mail.compose.gateway.message,model_mail_compose_gateway_message,base.group_user,1,1,1,0
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"
|
|
12
12
|
/>
|
|
13
13
|
</record>
|
|
14
|
-
<record id="
|
|
15
|
-
<field name="name">
|
|
16
|
-
<field name="model_id" ref="mail.
|
|
14
|
+
<record id="discuss_channel_gateway_rule" model="ir.rule">
|
|
15
|
+
<field name="name">discuss.channel: access gateway</field>
|
|
16
|
+
<field name="model_id" ref="mail.model_discuss_channel" />
|
|
17
17
|
<field name="groups" eval="[(4, ref('mail_gateway.gateway_user'))]" />
|
|
18
18
|
<field
|
|
19
19
|
name="domain_force"
|
|
20
|
-
>[('channel_type', '=', 'gateway'),
|
|
20
|
+
>[('channel_type', '=', 'gateway'), ('company_id', 'in', company_ids + [False]) ]</field>
|
|
21
21
|
<field name="perm_read" eval="True" />
|
|
22
22
|
<field name="perm_create" eval="False" />
|
|
23
23
|
<field name="perm_write" eval="True" />
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
<field name="model_id" ref="mail_gateway.model_mail_gateway" />
|
|
29
29
|
<field
|
|
30
30
|
name="domain_force"
|
|
31
|
-
>[
|
|
31
|
+
>[('company_id', 'in', company_ids + [False]) ]</field>
|
|
32
32
|
<field name="perm_read" eval="True" />
|
|
33
33
|
<field name="perm_create" eval="True" />
|
|
34
34
|
<field name="perm_write" eval="True" />
|
|
@@ -39,17 +39,17 @@
|
|
|
39
39
|
<field name="model_id" ref="mail_gateway.model_res_partner_gateway_channel" />
|
|
40
40
|
<field
|
|
41
41
|
name="domain_force"
|
|
42
|
-
>[
|
|
42
|
+
>[('company_id', 'in', company_ids + [False]) ]</field>
|
|
43
43
|
<field name="perm_read" eval="True" />
|
|
44
44
|
<field name="perm_create" eval="True" />
|
|
45
45
|
<field name="perm_write" eval="True" />
|
|
46
46
|
<field name="perm_unlink" eval="True" />
|
|
47
47
|
</record>
|
|
48
|
-
<record id="
|
|
48
|
+
<record id="ir_rule_discuss_channel_partner_group_user" model="ir.rule">
|
|
49
49
|
<field
|
|
50
50
|
name="name"
|
|
51
|
-
>
|
|
52
|
-
<field name="model_id" ref="mail.
|
|
51
|
+
>discuss.channel.member: write its own entries on gateway channels members</field>
|
|
52
|
+
<field name="model_id" ref="mail.model_discuss_channel_member" />
|
|
53
53
|
<field name="groups" eval="[(4, ref('mail_gateway.gateway_user'))]" />
|
|
54
54
|
<field name="domain_force">[('channel_id.channel_type', '=', 'gateway')]</field>
|
|
55
55
|
<field name="perm_read" eval="False" />
|
|
@@ -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>
|