odoo-addon-mail-gateway 16.0.1.0.0.2__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 (73) hide show
  1. odoo/addons/mail_gateway/README.rst +100 -0
  2. odoo/addons/mail_gateway/__init__.py +6 -0
  3. odoo/addons/mail_gateway/__manifest__.py +38 -0
  4. odoo/addons/mail_gateway/controllers/__init__.py +2 -0
  5. odoo/addons/mail_gateway/controllers/discuss.py +11 -0
  6. odoo/addons/mail_gateway/controllers/gateway.py +81 -0
  7. odoo/addons/mail_gateway/hooks.py +12 -0
  8. odoo/addons/mail_gateway/i18n/mail_gateway.pot +533 -0
  9. odoo/addons/mail_gateway/models/__init__.py +10 -0
  10. odoo/addons/mail_gateway/models/ir_websocket.py +21 -0
  11. odoo/addons/mail_gateway/models/mail_channel.py +79 -0
  12. odoo/addons/mail_gateway/models/mail_gateway.py +149 -0
  13. odoo/addons/mail_gateway/models/mail_gateway_abstract.py +82 -0
  14. odoo/addons/mail_gateway/models/mail_guest.py +18 -0
  15. odoo/addons/mail_gateway/models/mail_message.py +123 -0
  16. odoo/addons/mail_gateway/models/mail_notification.py +43 -0
  17. odoo/addons/mail_gateway/models/mail_thread.py +85 -0
  18. odoo/addons/mail_gateway/models/res_partner.py +89 -0
  19. odoo/addons/mail_gateway/models/res_users.py +16 -0
  20. odoo/addons/mail_gateway/readme/CONFIGURATION.rst +4 -0
  21. odoo/addons/mail_gateway/readme/CONTRIBUTORS.rst +2 -0
  22. odoo/addons/mail_gateway/readme/CREDITS.rst +1 -0
  23. odoo/addons/mail_gateway/readme/DESCRIPTION.rst +5 -0
  24. odoo/addons/mail_gateway/readme/USAGE.rst +9 -0
  25. odoo/addons/mail_gateway/security/ir.model.access.csv +9 -0
  26. odoo/addons/mail_gateway/security/security.xml +61 -0
  27. odoo/addons/mail_gateway/static/description/icon.png +0 -0
  28. odoo/addons/mail_gateway/static/description/index.html +441 -0
  29. odoo/addons/mail_gateway/static/src/components/chatter/chatter.xml +40 -0
  30. odoo/addons/mail_gateway/static/src/components/composer/composer.xml +24 -0
  31. odoo/addons/mail_gateway/static/src/components/discuss_sidebar/discuss_sidebar.xml +17 -0
  32. odoo/addons/mail_gateway/static/src/components/gateway_follower/gateway_follower.esm.js +31 -0
  33. odoo/addons/mail_gateway/static/src/components/gateway_follower/gateway_follower.scss +12 -0
  34. odoo/addons/mail_gateway/static/src/components/gateway_follower/gateway_follower.xml +30 -0
  35. odoo/addons/mail_gateway/static/src/components/message/message.xml +22 -0
  36. odoo/addons/mail_gateway/static/src/components/message_notification_popover_content/message_notification_popover_content.xml +15 -0
  37. odoo/addons/mail_gateway/static/src/models/channel.esm.js +33 -0
  38. odoo/addons/mail_gateway/static/src/models/channel_member_view.esm.js +39 -0
  39. odoo/addons/mail_gateway/static/src/models/chatter.esm.js +41 -0
  40. odoo/addons/mail_gateway/static/src/models/composer.esm.js +32 -0
  41. odoo/addons/mail_gateway/static/src/models/composer_gateway_follower.esm.js +32 -0
  42. odoo/addons/mail_gateway/static/src/models/composer_view.esm.js +56 -0
  43. odoo/addons/mail_gateway/static/src/models/discuss.esm.js +51 -0
  44. odoo/addons/mail_gateway/static/src/models/discuss_sidebar_category.esm.js +128 -0
  45. odoo/addons/mail_gateway/static/src/models/discuss_sidebar_category_item.esm.js +51 -0
  46. odoo/addons/mail_gateway/static/src/models/gateway.esm.js +16 -0
  47. odoo/addons/mail_gateway/static/src/models/gateway_channel.esm.js +14 -0
  48. odoo/addons/mail_gateway/static/src/models/gateway_channel_view.esm.js +15 -0
  49. odoo/addons/mail_gateway/static/src/models/guest.esm.js +10 -0
  50. odoo/addons/mail_gateway/static/src/models/message.esm.js +76 -0
  51. odoo/addons/mail_gateway/static/src/models/message_action.esm.js +45 -0
  52. odoo/addons/mail_gateway/static/src/models/message_action_list.esm.js +37 -0
  53. odoo/addons/mail_gateway/static/src/models/message_action_view.esm.js +91 -0
  54. odoo/addons/mail_gateway/static/src/models/message_view.esm.js +13 -0
  55. odoo/addons/mail_gateway/static/src/models/messaging_initializer.esm.js +24 -0
  56. odoo/addons/mail_gateway/static/src/models/notification.esm.js +20 -0
  57. odoo/addons/mail_gateway/static/src/models/partner.esm.js +11 -0
  58. odoo/addons/mail_gateway/static/src/models/thread.esm.js +77 -0
  59. odoo/addons/mail_gateway/tests/__init__.py +0 -0
  60. odoo/addons/mail_gateway/tests/common.py +21 -0
  61. odoo/addons/mail_gateway/views/mail_gateway.xml +93 -0
  62. odoo/addons/mail_gateway/views/res_partner_gateway_channel.xml +59 -0
  63. odoo/addons/mail_gateway/wizards/__init__.py +3 -0
  64. odoo/addons/mail_gateway/wizards/mail_guest_manage.py +58 -0
  65. odoo/addons/mail_gateway/wizards/mail_guest_manage.xml +37 -0
  66. odoo/addons/mail_gateway/wizards/mail_message_gateway_link.py +42 -0
  67. odoo/addons/mail_gateway/wizards/mail_message_gateway_link.xml +28 -0
  68. odoo/addons/mail_gateway/wizards/mail_message_gateway_send.py +20 -0
  69. odoo/addons/mail_gateway/wizards/mail_message_gateway_send.xml +39 -0
  70. odoo_addon_mail_gateway-16.0.1.0.0.2.dist-info/METADATA +118 -0
  71. odoo_addon_mail_gateway-16.0.1.0.0.2.dist-info/RECORD +73 -0
  72. odoo_addon_mail_gateway-16.0.1.0.0.2.dist-info/WHEEL +5 -0
  73. odoo_addon_mail_gateway-16.0.1.0.0.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <templates xml:space="preserve">
3
+
4
+ <t t-inherit="mail.Message" t-inherit-mode="extension">
5
+ <xpath expr="//small[hasclass('o_Message_originThread')]/.." position="after">
6
+ <t t-if="messageView.message.gatewayThread">
7
+ <small
8
+ class="o_Message_originThread me-2"
9
+ t-att-class="{ 'o-message-selected text-600': messageView.isSelected, 'text-500': !messageView.isSelected }"
10
+ >
11
+ on <a
12
+ class="o_Message_originThreadLink fs-6"
13
+ t-att-href="messageView.message.gatewayThread.url"
14
+ t-on-click="messageView.onClickGatewayThread"
15
+ ><t t-if="messageView.message.gatewayThread.displayName"><t
16
+ t-esc="messageView.message.gatewayThread.displayName"
17
+ /></t><t t-else="">document</t></a>
18
+ </small>
19
+ </t>
20
+ </xpath>
21
+ </t>
22
+ </templates>
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <templates xml:space="preserve">
3
+ <t t-inherit="mail.MessageNotificationPopoverContent" t-inherit-mode="extension">
4
+ <xpath
5
+ expr="//div[hasclass('o_MessageNotificationPopoverContent_notification')]"
6
+ position="inside"
7
+ >
8
+ <span
9
+ class="o_MessageNotificationPopoverContent_notificationPartnerName"
10
+ t-esc="notification.channel_name"
11
+ t-if="notification.notification_type == 'gateway'"
12
+ />
13
+ </xpath>
14
+ </t>
15
+ </templates>
@@ -0,0 +1,33 @@
1
+ /** @odoo-module **/
2
+
3
+ import {clear} from "@mail/model/model_field_command";
4
+ import {registerPatch} from "@mail/model/model_core";
5
+
6
+ registerPatch({
7
+ name: "Channel",
8
+ fields: {
9
+ discussSidebarCategory: {
10
+ compute() {
11
+ // On gateway channels we must set the right category
12
+ if (this.thread && this.thread.gateway) {
13
+ const category = this.messaging.discuss.categoryGateways.filter(
14
+ (ctg) => ctg.gateway === this.thread.gateway
15
+ );
16
+ if (category.length > 0) {
17
+ return category[0];
18
+ }
19
+ }
20
+ return this._super();
21
+ },
22
+ },
23
+ correspondent: {
24
+ compute() {
25
+ // We will not set a correspondent on gateways, as it gets yourself.
26
+ if (this.channel_type === "gateway") {
27
+ return clear();
28
+ }
29
+ return this._super();
30
+ },
31
+ },
32
+ },
33
+ });
@@ -0,0 +1,39 @@
1
+ /** @odoo-module **/
2
+
3
+ import {registerPatch} from "@mail/model/model_core";
4
+
5
+ registerPatch({
6
+ name: "ChannelMemberView",
7
+ recordMethods: {
8
+ onClickMember(ev) {
9
+ if (
10
+ this.channelMember.persona.guest &&
11
+ this.channelMember.persona.guest.gateway
12
+ ) {
13
+ ev.stopPropagation();
14
+ return this.env.services.action.doAction({
15
+ name: this.env._t("Manage guest"),
16
+ type: "ir.actions.act_window",
17
+ res_model: "mail.guest.manage",
18
+ context: {default_guest_id: this.channelMember.persona.guest.id},
19
+ views: [[false, "form"]],
20
+ target: "new",
21
+ });
22
+ }
23
+ return this._super();
24
+ },
25
+ },
26
+ fields: {
27
+ hasOpenChat: {
28
+ compute() {
29
+ return (
30
+ this._super() ||
31
+ Boolean(
32
+ this.channelMember.persona.guest &&
33
+ this.channelMember.persona.guest.gateway
34
+ )
35
+ );
36
+ },
37
+ },
38
+ },
39
+ });
@@ -0,0 +1,41 @@
1
+ /** @odoo-module **/
2
+
3
+ import {clear} from "@mail/model/model_field_command";
4
+ import {registerPatch} from "@mail/model/model_core";
5
+
6
+ registerPatch({
7
+ name: "Chatter",
8
+ recordMethods: {
9
+ onClickLogNote() {
10
+ if (this.composerView && this.composerView.composer.isGateway) {
11
+ this.update({composerView: clear()});
12
+ }
13
+ this._super(...arguments);
14
+ if (this.composerView) {
15
+ this.composerView.composer.update({isGateway: false});
16
+ }
17
+ },
18
+ onClickSendMessage() {
19
+ if (this.composerView && this.composerView.composer.isGateway) {
20
+ this.update({composerView: clear()});
21
+ }
22
+ this._super(...arguments);
23
+ if (this.composerView) {
24
+ this.composerView.composer.update({isGateway: false});
25
+ }
26
+ },
27
+ onClickGatewayMessage() {
28
+ if (this.composerView && this.composerView.composer.isGateway) {
29
+ this.update({composerView: clear()});
30
+ } else {
31
+ this.showGatewayComposerView();
32
+ }
33
+ },
34
+ showGatewayComposerView() {
35
+ this.update({composerView: {}});
36
+ this.composerView.composer.update({isLog: false, isGateway: true});
37
+ this.focus();
38
+ },
39
+ },
40
+ fields: {},
41
+ });
@@ -0,0 +1,32 @@
1
+ /** @odoo-module **/
2
+
3
+ import {attr, many} from "@mail/model/model_field";
4
+ import {clear} from "@mail/model/model_field_command";
5
+ import {registerPatch} from "@mail/model/model_core";
6
+
7
+ registerPatch({
8
+ name: "Composer",
9
+ fields: {
10
+ isGateway: attr({
11
+ default: false,
12
+ }),
13
+ composerGatewayFollowers: many("composerGatewayFollower", {
14
+ compute() {
15
+ if (this.thread && this.isGateway) {
16
+ return this.thread.followers
17
+ .filter(
18
+ (follower) => follower.partner.gateway_channels.length > 0
19
+ )
20
+ .map((follower) => {
21
+ return {
22
+ follower,
23
+ channel: follower.partner.gateway_channels[0].id,
24
+ };
25
+ });
26
+ }
27
+ return clear();
28
+ },
29
+ inverse: "composer",
30
+ }),
31
+ },
32
+ });
@@ -0,0 +1,32 @@
1
+ /** @odoo-module **/
2
+
3
+ import {attr, one} from "@mail/model/model_field";
4
+ import {registerModel} from "@mail/model/model_core";
5
+
6
+ registerModel({
7
+ name: "composerGatewayFollower",
8
+ recordMethods: {
9
+ _getMessageData() {
10
+ return {
11
+ partner_id: this.follower.partner.id,
12
+ channel_type: "gateway",
13
+ gateway_channel_id: this.channel,
14
+ };
15
+ },
16
+ },
17
+ fields: {
18
+ component: attr(),
19
+ follower: one("Follower", {identifying: true}),
20
+ composer: one("Composer", {
21
+ identifying: true,
22
+ inverse: "composerGatewayFollowers",
23
+ }),
24
+ channel_type: attr({}),
25
+ channel: attr(),
26
+ hasGatewayChannels: attr({
27
+ compute() {
28
+ return this.follower.partner.gateway_channels.length > 0;
29
+ },
30
+ }),
31
+ },
32
+ });
@@ -0,0 +1,56 @@
1
+ /** @odoo-module **/
2
+
3
+ import {clear} from "@mail/model/model_field_command";
4
+ import {one} from "@mail/model/model_field";
5
+ import {registerPatch} from "@mail/model/model_core";
6
+
7
+ registerPatch({
8
+ name: "ComposerView",
9
+ recordMethods: {
10
+ _getMessageData() {
11
+ var result = this._super(...arguments);
12
+ if (this.composer.isGateway) {
13
+ result.gateway_notifications =
14
+ this.composer.composerGatewayFollowers.map((follower) => {
15
+ return follower._getMessageData();
16
+ });
17
+ }
18
+ return result;
19
+ },
20
+ },
21
+ fields: {
22
+ hasFollowers: {
23
+ compute() {
24
+ if (this.composer.isGateway) {
25
+ return false;
26
+ }
27
+ return this._super();
28
+ },
29
+ },
30
+ hasHeader: {
31
+ compute() {
32
+ return Boolean(this._super() || this.composer.isGateway);
33
+ },
34
+ },
35
+ isExpandable: {
36
+ /*
37
+ We will not allow to expand on this composer due to all complexity of selection
38
+ */
39
+ compute() {
40
+ if (this.composer.isGateway) {
41
+ return clear();
42
+ }
43
+ return this._super();
44
+ },
45
+ },
46
+ composerGatewayChannelView: one("GatewayChannelView", {
47
+ compute() {
48
+ if (this.composer.isGateway) {
49
+ return {};
50
+ }
51
+ return clear();
52
+ },
53
+ inverse: "composerViewOwner",
54
+ }),
55
+ },
56
+ });
@@ -0,0 +1,51 @@
1
+ /** @odoo-module **/
2
+
3
+ import {many} from "@mail/model/model_field";
4
+ import {registerPatch} from "@mail/model/model_core";
5
+
6
+ registerPatch({
7
+ name: "Discuss",
8
+ fields: {
9
+ /**
10
+ * Discuss sidebar category for `gateway` channel threads.
11
+ */
12
+ categoryGateways: many("DiscussSidebarCategory", {
13
+ inverse: "discussAsGateways",
14
+ }),
15
+ },
16
+ recordMethods: {
17
+ async handleAddGatewayAutocompleteSource(req, res, gateway_id) {
18
+ this.discussView.update({addingChannelValue: req.term});
19
+ const threads = await this.messaging.models.Thread.searchGatewaysToOpen({
20
+ limit: 10,
21
+ searchTerm: req.term,
22
+ gateway_id,
23
+ });
24
+ const items = threads.map((thread) => {
25
+ const escapedName = escape(thread.name);
26
+ return {
27
+ id: thread.id,
28
+ label: escapedName,
29
+ value: escapedName,
30
+ gateway_id: gateway_id,
31
+ };
32
+ });
33
+ res(items);
34
+ },
35
+ async handleAddGatewayAutocompleteSelect(ev, ui, gateway_id) {
36
+ // Necessary in order to prevent AutocompleteSelect event's default
37
+ // behaviour as html tags visible for a split second in text area
38
+ ev.preventDefault();
39
+ const channel = this.messaging.models.Thread.insert({
40
+ id: ui.item.id,
41
+ model: "mail.channel",
42
+ gateway_id: gateway_id,
43
+ });
44
+ await channel.join();
45
+ // Channel must be pinned immediately to be able to open it before
46
+ // the result of join is received on the bus.
47
+ channel.update({isServerPinned: true});
48
+ channel.open();
49
+ },
50
+ },
51
+ });
@@ -0,0 +1,128 @@
1
+ /** @odoo-module **/
2
+
3
+ import {attr, one} from "@mail/model/model_field";
4
+ import {clear} from "@mail/model/model_field_command";
5
+ import {registerPatch} from "@mail/model/model_core";
6
+
7
+ registerPatch({
8
+ name: "DiscussSidebarCategory",
9
+ fields: {
10
+ gateway_id: attr({identifying: true}),
11
+ gateway: one("Gateway", {inverse: "categories"}),
12
+ discussAsGateways: one("Discuss", {
13
+ inverse: "categoryGateways",
14
+ }),
15
+ hasAddCommand: {
16
+ compute() {
17
+ if (this.gateway_id) {
18
+ return true;
19
+ }
20
+ return this._super();
21
+ },
22
+ },
23
+ activeItem: {
24
+ compute() {
25
+ // We need to adapt this function to refresh the right category only
26
+ const channel =
27
+ this.messaging.discuss.activeThread &&
28
+ this.messaging.discuss.activeThread.channel;
29
+ if (
30
+ channel &&
31
+ this.gateway_id &&
32
+ this.supportedChannelTypes.includes(channel.channel_type) &&
33
+ channel.thread.gateway_id !== this.gateway_id
34
+ ) {
35
+ return clear();
36
+ }
37
+ return this._super();
38
+ },
39
+ },
40
+ autocompleteMethod: {
41
+ compute() {
42
+ if (this.gateway_id) {
43
+ return "gateway";
44
+ }
45
+ return this._super();
46
+ },
47
+ },
48
+ newItemPlaceholderText: {
49
+ compute() {
50
+ if (this.gateway_id) {
51
+ return this.env._t("Find a gateway channel...");
52
+ }
53
+ return this._super();
54
+ },
55
+ },
56
+ isServerOpen: {
57
+ compute() {
58
+ // There is no server state for non-users (guests)
59
+ if (!this.messaging.currentUser) {
60
+ return clear();
61
+ }
62
+ if (!this.messaging.currentUser.res_users_settings_id) {
63
+ return clear();
64
+ }
65
+ if (this.gateway_id) {
66
+ return true;
67
+ }
68
+ return this._super();
69
+ },
70
+ },
71
+ name: {
72
+ compute() {
73
+ if (this.gateway_id) {
74
+ return this.gateway.name;
75
+ }
76
+ return this._super();
77
+ },
78
+ },
79
+
80
+ categoryItemsOrderedByLastAction: {
81
+ compute() {
82
+ if (this.gateway_id) {
83
+ return this.categoryItems;
84
+ }
85
+ return this._super();
86
+ },
87
+ },
88
+ orderedCategoryItems: {
89
+ compute() {
90
+ if (this.gateway_id) {
91
+ return this.categoryItemsOrderedByLastAction;
92
+ }
93
+ return this._super();
94
+ },
95
+ },
96
+ supportedChannelTypes: {
97
+ compute() {
98
+ if (this.gateway_id) {
99
+ return ["gateway"];
100
+ }
101
+ return this._super();
102
+ },
103
+ },
104
+ },
105
+ recordMethods: {
106
+ onAddItemAutocompleteSource(req, res) {
107
+ if (this.autocompleteMethod === "gateway") {
108
+ this.messaging.discuss.handleAddGatewayAutocompleteSource(
109
+ req,
110
+ res,
111
+ this.gateway_id
112
+ );
113
+ }
114
+ return this._super(...arguments);
115
+ },
116
+
117
+ onAddItemAutocompleteSelect(ev, ui) {
118
+ if (this.autocompleteMethod === "gateway") {
119
+ return this.messaging.discuss.handleAddGatewayAutocompleteSelect(
120
+ ev,
121
+ ui,
122
+ this.gateway_id
123
+ );
124
+ }
125
+ return this._super(...arguments);
126
+ },
127
+ },
128
+ });
@@ -0,0 +1,51 @@
1
+ /** @odoo-module **/
2
+
3
+ import {clear} from "@mail/model/model_field_command";
4
+ import {registerPatch} from "@mail/model/model_core";
5
+
6
+ registerPatch({
7
+ name: "DiscussSidebarCategoryItem",
8
+ fields: {
9
+ avatarUrl: {
10
+ compute() {
11
+ // We will use the avatar provied by the channel by default
12
+ if (this.channel.channel_type === "gateway") {
13
+ return `/web/image/mail.channel/${this.channel.id}/avatar_128?unique=${this.channel.avatarCacheKey}`;
14
+ }
15
+ return this._super();
16
+ },
17
+ },
18
+ categoryCounterContribution: {
19
+ compute() {
20
+ if (this.channel.channel_type === "gateway") {
21
+ return this.channel.localMessageUnreadCounter > 0 ? 1 : 0;
22
+ }
23
+ return this._super();
24
+ },
25
+ },
26
+ counter: {
27
+ compute() {
28
+ if (this.channel.channel_type === "gateway") {
29
+ return this.channel.localMessageUnreadCounter;
30
+ }
31
+ return this._super();
32
+ },
33
+ },
34
+ hasThreadIcon: {
35
+ compute() {
36
+ if (this.channel.channel_type === "gateway") {
37
+ return clear();
38
+ }
39
+ return this._super();
40
+ },
41
+ },
42
+ hasUnpinCommand: {
43
+ compute() {
44
+ if (this.channel.channel_type === "gateway") {
45
+ return !this.channel.localMessageUnreadCounter;
46
+ }
47
+ return this._super();
48
+ },
49
+ },
50
+ },
51
+ });
@@ -0,0 +1,16 @@
1
+ /** @odoo-module **/
2
+
3
+ import {attr, many} from "@mail/model/model_field";
4
+ import {registerModel} from "@mail/model/model_core";
5
+
6
+ registerModel({
7
+ name: "Gateway",
8
+ fields: {
9
+ id: attr({identifying: true}),
10
+ name: attr(),
11
+ type: attr(),
12
+ categories: many("DiscussSidebarCategory", {
13
+ inverse: "gateway",
14
+ }),
15
+ },
16
+ });
@@ -0,0 +1,14 @@
1
+ /** @odoo-module **/
2
+
3
+ import {attr, one} from "@mail/model/model_field";
4
+ import {registerModel} from "@mail/model/model_core";
5
+
6
+ registerModel({
7
+ name: "GatewayChannel",
8
+ fields: {
9
+ id: attr({identifying: true}),
10
+ name: attr(),
11
+ gateway: one("Gateway"),
12
+ partner: one("Partner", {inverse: "gateway_channels"}),
13
+ },
14
+ });
@@ -0,0 +1,15 @@
1
+ /** @odoo-module **/
2
+
3
+ import {attr, one} from "@mail/model/model_field";
4
+ import {registerModel} from "@mail/model/model_core";
5
+
6
+ registerModel({
7
+ name: "GatewayChannelView",
8
+ fields: {
9
+ component: attr(),
10
+ composerViewOwner: one("ComposerView", {
11
+ identifying: true,
12
+ inverse: "composerGatewayChannelView",
13
+ }),
14
+ },
15
+ });
@@ -0,0 +1,10 @@
1
+ /** @odoo-module **/
2
+ import {one} from "@mail/model/model_field";
3
+ import {registerPatch} from "@mail/model/model_core";
4
+
5
+ registerPatch({
6
+ name: "Guest",
7
+ fields: {
8
+ gateway: one("Gateway"),
9
+ },
10
+ });
@@ -0,0 +1,76 @@
1
+ /** @odoo-module **/
2
+
3
+ import {attr, one} from "@mail/model/model_field";
4
+ import {clear} from "@mail/model/model_field_command";
5
+ import {registerPatch} from "@mail/model/model_core";
6
+
7
+ registerPatch({
8
+ name: "Message",
9
+ fields: {
10
+ gateway_type: attr(),
11
+ gateway_channel_data: attr(),
12
+ gateway_thread_data: attr(),
13
+ gatewayThread: one("Thread", {
14
+ compute() {
15
+ if (
16
+ this.gateway_thread_data &&
17
+ Object.keys(this.gateway_thread_data).length > 0
18
+ ) {
19
+ return this.gateway_thread_data;
20
+ }
21
+ return clear();
22
+ },
23
+ inverse: "messagesAsGatewayThread",
24
+ }),
25
+ canBeDeleted: {
26
+ compute() {
27
+ if (
28
+ this.originThread &&
29
+ this.originThread.model !== "mail.channel" &&
30
+ this.gateway_type
31
+ ) {
32
+ return true;
33
+ }
34
+ if (
35
+ this.originThread &&
36
+ this.originThread.model === "mail.channel" &&
37
+ this.gateway_type
38
+ ) {
39
+ return false;
40
+ }
41
+ return this._super();
42
+ },
43
+ },
44
+ },
45
+ modelMethods: {
46
+ convertData(data) {
47
+ const data2 = this._super(data);
48
+ data2.gateway_type = data.gateway_type;
49
+ data2.gateway_channel_data = data.gateway_channel_data;
50
+ data2.gateway_thread_data = data.gateway_thread_data;
51
+ return data2;
52
+ },
53
+ },
54
+ recordMethods: {
55
+ /**
56
+ * @private
57
+ */
58
+ _computeGatewayData() {
59
+ if (
60
+ this.gateway_thread_data &&
61
+ Object.keys(this.gateway_thread_data).length > 0
62
+ ) {
63
+ this.update({gatewayThread: this.gateway_thread_data});
64
+ } else {
65
+ this.update({gatewayThread: clear()});
66
+ }
67
+ },
68
+ },
69
+
70
+ onChanges: [
71
+ {
72
+ dependencies: ["gateway_thread_data"],
73
+ methodName: "_computeGatewayData",
74
+ },
75
+ ],
76
+ });