Skip to content

Commit 4116f81

Browse files
committed
[MIG] mail_gateway: continue migration
1 parent 1825142 commit 4116f81

File tree

67 files changed

+689
-1063
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+689
-1063
lines changed

mail_gateway/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from . import controllers
22
from . import models
33

4-
# from . import services
54
from .hooks import pre_init_hook
65
from . import wizards

mail_gateway/__manifest__.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,16 @@
1919
"security/ir.model.access.csv",
2020
"views/mail_gateway.xml",
2121
"views/res_partner_gateway_channel.xml",
22+
"views/mail_guest_views.xml",
2223
],
2324
"assets": {
24-
"mail.assets_messaging": [
25-
"mail_gateway/static/src/models/**/*.js",
26-
],
2725
"web.assets_backend": [
28-
"mail_gateway/static/src/components/**/*.xml",
29-
"mail_gateway/static/src/components/**/*.js",
30-
"mail_gateway/static/src/components/**/*.scss",
31-
],
32-
"mail.assets_discuss_public": [
33-
"mail_gateway/static/src/components/**/*.xml",
34-
"mail_gateway/static/src/components/**/*.js",
35-
"mail_gateway/static/src/components/**/*.scss",
26+
"mail_gateway/static/src/components/**/*",
27+
"mail_gateway/static/src/core/**/*",
28+
"mail_gateway/static/src/models/**/*",
3629
],
30+
# "mail.assets_public": [
31+
# "mail_gateway/static/src/components/**/*",
32+
# ],
3733
},
3834
}

mail_gateway/controllers/gateway.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
from odoo.http import Controller, request, route
88

9+
from odoo.addons.mail.models.discuss.mail_guest import add_guest_to_context
10+
911
_logger = logging.getLogger(__name__)
1012

1113

@@ -17,6 +19,7 @@ class GatewayController(Controller):
1719
methods=["GET", "POST"],
1820
csrf=False,
1921
)
22+
@add_guest_to_context
2023
def post_update(self, usage, token, *args, **kwargs):
2124
if request.httprequest.method == "GET":
2225
bot_data = request.env["mail.gateway"]._get_gateway(

mail_gateway/hooks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ def pre_init_hook(env):
88
"""
99
env.cr.execute(
1010
"""ALTER TABLE mail_message
11-
ADD COLUMN gateway_channel_id int"""
11+
ADD COLUMN IF NOT EXISTS gateway_channel_id int"""
1212
)

mail_gateway/models/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
from . import ir_websocket
2+
from . import mail_gateway_abstract
13
from . import mail_message
24
from . import mail_notification
3-
from . import mail_channel
5+
from . import discuss_channel
46
from . import mail_gateway
5-
from . import ir_websocket
67
from . import res_partner
78
from . import mail_guest
8-
from . import mail_gateway_abstract
99
from . import res_users
10+
from . import res_users_settings
1011
from . import mail_thread
11-
12-
from . import discuss

mail_gateway/models/discuss/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

mail_gateway/models/discuss/discuss_channel.py renamed to mail_gateway/models/discuss_channel.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ class MailChannel(models.Model):
2626
required=False,
2727
)
2828

29+
def _compute_is_chat(self):
30+
res = super()._compute_is_chat()
31+
for record in self:
32+
if record.channel_type == "gateway":
33+
record.is_chat = True
34+
return res
35+
2936
def _channel_info(self):
3037
result = super()._channel_info()
3138
for record, item in zip(self, result, strict=True):

mail_gateway/models/ir_websocket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def _build_bus_channel_list(self, channels):
1414
result = super()._build_bus_channel_list(channels)
1515
if req.session.uid:
1616
if req.env.user.has_group("mail_gateway.gateway_user"):
17-
for channel in req.env["mail.channel"].search(
17+
for channel in req.env["discuss.channel"].search(
1818
[("channel_type", "=", "gateway")]
1919
):
2020
result.append(channel)

mail_gateway/models/mail_gateway.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def _compute_webhook_url(self):
5151

5252
def _get_channel_id(self, chat_token):
5353
return (
54-
self.env["mail.channel"]
54+
self.env["discuss.channel"]
5555
.search(
5656
[
5757
("gateway_channel_token", "=", str(chat_token)),

mail_gateway/models/mail_gateway_abstract.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ def _remove_webhook(self, gateway):
3333
def _get_channel(self, gateway, token, update, force_create=False):
3434
chat_id = gateway._get_channel_id(token)
3535
if chat_id:
36-
return gateway.env["mail.channel"].browse(chat_id)
36+
return gateway.env["discuss.channel"].browse(chat_id)
3737
if not force_create and gateway.has_new_channel_security:
3838
return False
39-
channel = gateway.env["mail.channel"].create(
39+
channel = gateway.env["discuss.channel"].create(
4040
self._get_channel_vals(gateway, token, update)
4141
)
4242
channel._broadcast(channel.channel_member_ids.mapped("partner_id").ids)

0 commit comments

Comments
 (0)