odoo-addon-mail-gateway-whatsapp 16.0.1.1.0.9__py3-none-any.whl → 18.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.
- odoo/addons/mail_gateway_whatsapp/README.rst +61 -45
- odoo/addons/mail_gateway_whatsapp/__manifest__.py +2 -6
- odoo/addons/mail_gateway_whatsapp/i18n/es.po +124 -136
- odoo/addons/mail_gateway_whatsapp/i18n/it.po +3 -13
- odoo/addons/mail_gateway_whatsapp/i18n/mail_gateway_whatsapp.pot +2 -57
- odoo/addons/mail_gateway_whatsapp/models/__init__.py +1 -1
- odoo/addons/mail_gateway_whatsapp/models/{mail_channel.py → discuss_channel.py} +5 -8
- odoo/addons/mail_gateway_whatsapp/models/mail_gateway.py +1 -1
- odoo/addons/mail_gateway_whatsapp/models/mail_gateway_whatsapp.py +35 -45
- odoo/addons/mail_gateway_whatsapp/models/mail_thread.py +3 -7
- odoo/addons/mail_gateway_whatsapp/models/mail_whatsapp_template.py +3 -5
- odoo/addons/mail_gateway_whatsapp/readme/CONFIGURE.md +35 -0
- odoo/addons/mail_gateway_whatsapp/readme/CONTRIBUTORS.md +7 -0
- odoo/addons/mail_gateway_whatsapp/readme/{CREDITS.rst → CREDITS.md} +2 -1
- odoo/addons/mail_gateway_whatsapp/readme/{DESCRIPTION.rst → DESCRIPTION.md} +2 -2
- odoo/addons/mail_gateway_whatsapp/readme/ROADMAP.md +4 -0
- odoo/addons/mail_gateway_whatsapp/readme/USAGE.md +3 -0
- odoo/addons/mail_gateway_whatsapp/static/description/index.html +55 -40
- odoo/addons/mail_gateway_whatsapp/static/src/components/message/message.xml +2 -2
- odoo/addons/mail_gateway_whatsapp/static/src/components/message/message_patch.esm.js +16 -0
- odoo/addons/mail_gateway_whatsapp/static/src/components/phone_field/phone_field.esm.js +3 -4
- odoo/addons/mail_gateway_whatsapp/static/src/components/phone_field/phone_field.xml +2 -2
- odoo/addons/mail_gateway_whatsapp/static/src/components/send_whatsapp_button/send_whatsapp_button.esm.js +6 -8
- odoo/addons/mail_gateway_whatsapp/static/src/components/send_whatsapp_button/send_whatsapp_button.xml +5 -2
- odoo/addons/mail_gateway_whatsapp/tests/test_mail_gateway_whatsapp.py +32 -30
- odoo/addons/mail_gateway_whatsapp/tools/const.py +1 -1
- odoo/addons/mail_gateway_whatsapp/views/mail_gateway.xml +30 -34
- odoo/addons/mail_gateway_whatsapp/views/mail_whatsapp_template_views.xml +15 -32
- odoo/addons/mail_gateway_whatsapp/wizards/mail_compose_gateway_message.py +1 -3
- odoo/addons/mail_gateway_whatsapp/wizards/mail_compose_gateway_message.xml +2 -7
- odoo/addons/mail_gateway_whatsapp/wizards/whatsapp_composer.py +1 -2
- odoo/addons/mail_gateway_whatsapp/wizards/whatsapp_composer.xml +3 -13
- {odoo_addon_mail_gateway_whatsapp-16.0.1.1.0.9.dist-info → odoo_addon_mail_gateway_whatsapp-18.0.1.0.0.2.dist-info}/METADATA +69 -52
- odoo_addon_mail_gateway_whatsapp-18.0.1.0.0.2.dist-info/RECORD +46 -0
- {odoo_addon_mail_gateway_whatsapp-16.0.1.1.0.9.dist-info → odoo_addon_mail_gateway_whatsapp-18.0.1.0.0.2.dist-info}/WHEEL +1 -1
- odoo_addon_mail_gateway_whatsapp-18.0.1.0.0.2.dist-info/top_level.txt +1 -0
- odoo/addons/mail_gateway_whatsapp/i18n/es_VE.po +0 -1181
- odoo/addons/mail_gateway_whatsapp/readme/CONFIGURE.rst +0 -31
- odoo/addons/mail_gateway_whatsapp/readme/CONTRIBUTORS.rst +0 -5
- odoo/addons/mail_gateway_whatsapp/readme/ROADMAP.rst +0 -4
- odoo/addons/mail_gateway_whatsapp/readme/USAGE.rst +0 -3
- odoo/addons/mail_gateway_whatsapp/static/src/models/message.esm.js +0 -21
- odoo/addons/mail_gateway_whatsapp/static/src/models/message_view.esm.js +0 -25
- odoo/addons/mail_gateway_whatsapp/static/src/models/notification.esm.js +0 -25
- odoo_addon_mail_gateway_whatsapp-16.0.1.1.0.9.dist-info/RECORD +0 -49
- odoo_addon_mail_gateway_whatsapp-16.0.1.1.0.9.dist-info/top_level.txt +0 -1
|
@@ -6,7 +6,7 @@ msgid ""
|
|
|
6
6
|
msgstr ""
|
|
7
7
|
"Project-Id-Version: Odoo Server 16.0\n"
|
|
8
8
|
"Report-Msgid-Bugs-To: \n"
|
|
9
|
-
"PO-Revision-Date: 2025-
|
|
9
|
+
"PO-Revision-Date: 2025-01-09 13:06+0000\n"
|
|
10
10
|
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
|
|
11
11
|
"Language-Team: none\n"
|
|
12
12
|
"Language: it\n"
|
|
@@ -14,7 +14,7 @@ msgstr ""
|
|
|
14
14
|
"Content-Type: text/plain; charset=UTF-8\n"
|
|
15
15
|
"Content-Transfer-Encoding: \n"
|
|
16
16
|
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
|
17
|
-
"X-Generator: Weblate 5.
|
|
17
|
+
"X-Generator: Weblate 5.6.2\n"
|
|
18
18
|
|
|
19
19
|
#. module: mail_gateway_whatsapp
|
|
20
20
|
#: model_terms:ir.ui.view,arch_db:mail_gateway_whatsapp.mail_gateway_form_view
|
|
@@ -111,7 +111,7 @@ msgstr "Azerbaigiano"
|
|
|
111
111
|
#. module: mail_gateway_whatsapp
|
|
112
112
|
#: model_terms:ir.ui.view,arch_db:mail_gateway_whatsapp.view_mail_whatsapp_template_form
|
|
113
113
|
msgid "Back to draft"
|
|
114
|
-
msgstr "
|
|
114
|
+
msgstr "Ritorna a bozza"
|
|
115
115
|
|
|
116
116
|
#. module: mail_gateway_whatsapp
|
|
117
117
|
#: model:ir.model.fields.selection,name:mail_gateway_whatsapp.selection__mail_whatsapp_template__language__bn
|
|
@@ -699,21 +699,11 @@ msgstr "Contenuto messaggio"
|
|
|
699
699
|
msgid "Message Delivery error"
|
|
700
700
|
msgstr "Errore di consegna messaggio"
|
|
701
701
|
|
|
702
|
-
#. module: mail_gateway_whatsapp
|
|
703
|
-
#: model:ir.model.fields,field_description:mail_gateway_whatsapp.field_res_partner__message_search
|
|
704
|
-
msgid "Message Search"
|
|
705
|
-
msgstr "Ricerca messaggio"
|
|
706
|
-
|
|
707
702
|
#. module: mail_gateway_whatsapp
|
|
708
703
|
#: model:ir.model.fields,help:mail_gateway_whatsapp.field_res_partner__message_content
|
|
709
704
|
msgid "Message content, to be used only in searches"
|
|
710
705
|
msgstr "Contenuto messaggio, da utilizzare solo nelle ricerche"
|
|
711
706
|
|
|
712
|
-
#. module: mail_gateway_whatsapp
|
|
713
|
-
#: model:ir.model.fields,help:mail_gateway_whatsapp.field_res_partner__message_search
|
|
714
|
-
msgid "Message search, to be used only in searches"
|
|
715
|
-
msgstr "Ricerca messaggio, da utilizzare solo nelle ricerche"
|
|
716
|
-
|
|
717
707
|
#. module: mail_gateway_whatsapp
|
|
718
708
|
#: model:ir.model.fields,field_description:mail_gateway_whatsapp.field_res_partner__message_ids
|
|
719
709
|
msgid "Messages"
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
#
|
|
5
5
|
msgid ""
|
|
6
6
|
msgstr ""
|
|
7
|
-
"Project-Id-Version: Odoo Server
|
|
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"
|
|
@@ -125,7 +125,6 @@ msgstr ""
|
|
|
125
125
|
#. module: mail_gateway_whatsapp
|
|
126
126
|
#. odoo-python
|
|
127
127
|
#: code:addons/mail_gateway_whatsapp/wizards/whatsapp_composer.py:0
|
|
128
|
-
#, python-format
|
|
129
128
|
msgid "Body is required"
|
|
130
129
|
msgstr ""
|
|
131
130
|
|
|
@@ -254,7 +253,7 @@ msgid "Disabled"
|
|
|
254
253
|
msgstr ""
|
|
255
254
|
|
|
256
255
|
#. module: mail_gateway_whatsapp
|
|
257
|
-
#: model:ir.model,name:mail_gateway_whatsapp.
|
|
256
|
+
#: model:ir.model,name:mail_gateway_whatsapp.model_discuss_channel
|
|
258
257
|
msgid "Discussion Channel"
|
|
259
258
|
msgstr ""
|
|
260
259
|
|
|
@@ -324,11 +323,6 @@ msgstr ""
|
|
|
324
323
|
msgid "Export Template"
|
|
325
324
|
msgstr ""
|
|
326
325
|
|
|
327
|
-
#. module: mail_gateway_whatsapp
|
|
328
|
-
#: model:ir.model.fields,field_description:mail_gateway_whatsapp.field_res_partner__failed_message_ids
|
|
329
|
-
msgid "Failed Messages"
|
|
330
|
-
msgstr ""
|
|
331
|
-
|
|
332
326
|
#. module: mail_gateway_whatsapp
|
|
333
327
|
#: model:ir.model.fields,help:mail_gateway_whatsapp.field_res_partner__phone_sanitized
|
|
334
328
|
msgid ""
|
|
@@ -570,12 +564,6 @@ msgstr ""
|
|
|
570
564
|
msgid "Lao"
|
|
571
565
|
msgstr ""
|
|
572
566
|
|
|
573
|
-
#. module: mail_gateway_whatsapp
|
|
574
|
-
#: model:ir.model.fields,field_description:mail_gateway_whatsapp.field_mail_whatsapp_template____last_update
|
|
575
|
-
#: model:ir.model.fields,field_description:mail_gateway_whatsapp.field_whatsapp_composer____last_update
|
|
576
|
-
msgid "Last Modified on"
|
|
577
|
-
msgstr ""
|
|
578
|
-
|
|
579
567
|
#. module: mail_gateway_whatsapp
|
|
580
568
|
#: model:ir.model.fields,field_description:mail_gateway_whatsapp.field_mail_whatsapp_template__write_uid
|
|
581
569
|
#: model:ir.model.fields,field_description:mail_gateway_whatsapp.field_whatsapp_composer__write_uid
|
|
@@ -623,11 +611,6 @@ msgstr ""
|
|
|
623
611
|
msgid "Mail WhatsApp template"
|
|
624
612
|
msgstr ""
|
|
625
613
|
|
|
626
|
-
#. module: mail_gateway_whatsapp
|
|
627
|
-
#: model:ir.model.fields,field_description:mail_gateway_whatsapp.field_res_partner__message_main_attachment_id
|
|
628
|
-
msgid "Main Attachment"
|
|
629
|
-
msgstr ""
|
|
630
|
-
|
|
631
614
|
#. module: mail_gateway_whatsapp
|
|
632
615
|
#: model:ir.model.fields.selection,name:mail_gateway_whatsapp.selection__mail_whatsapp_template__language__ms
|
|
633
616
|
msgid "Malay"
|
|
@@ -653,31 +636,11 @@ msgstr ""
|
|
|
653
636
|
msgid "Message"
|
|
654
637
|
msgstr ""
|
|
655
638
|
|
|
656
|
-
#. module: mail_gateway_whatsapp
|
|
657
|
-
#: model:ir.model.fields,field_description:mail_gateway_whatsapp.field_res_partner__message_content
|
|
658
|
-
msgid "Message Content"
|
|
659
|
-
msgstr ""
|
|
660
|
-
|
|
661
639
|
#. module: mail_gateway_whatsapp
|
|
662
640
|
#: model:ir.model.fields,field_description:mail_gateway_whatsapp.field_res_partner__message_has_error
|
|
663
641
|
msgid "Message Delivery error"
|
|
664
642
|
msgstr ""
|
|
665
643
|
|
|
666
|
-
#. module: mail_gateway_whatsapp
|
|
667
|
-
#: model:ir.model.fields,field_description:mail_gateway_whatsapp.field_res_partner__message_search
|
|
668
|
-
msgid "Message Search"
|
|
669
|
-
msgstr ""
|
|
670
|
-
|
|
671
|
-
#. module: mail_gateway_whatsapp
|
|
672
|
-
#: model:ir.model.fields,help:mail_gateway_whatsapp.field_res_partner__message_content
|
|
673
|
-
msgid "Message content, to be used only in searches"
|
|
674
|
-
msgstr ""
|
|
675
|
-
|
|
676
|
-
#. module: mail_gateway_whatsapp
|
|
677
|
-
#: model:ir.model.fields,help:mail_gateway_whatsapp.field_res_partner__message_search
|
|
678
|
-
msgid "Message search, to be used only in searches"
|
|
679
|
-
msgstr ""
|
|
680
|
-
|
|
681
644
|
#. module: mail_gateway_whatsapp
|
|
682
645
|
#: model:ir.model.fields,field_description:mail_gateway_whatsapp.field_res_partner__message_ids
|
|
683
646
|
msgid "Messages"
|
|
@@ -691,7 +654,6 @@ msgstr ""
|
|
|
691
654
|
#. module: mail_gateway_whatsapp
|
|
692
655
|
#. odoo-python
|
|
693
656
|
#: code:addons/mail_gateway_whatsapp/models/mail_gateway_whatsapp.py:0
|
|
694
|
-
#, python-format
|
|
695
657
|
msgid "Mimetype is not valid"
|
|
696
658
|
msgstr ""
|
|
697
659
|
|
|
@@ -781,7 +743,6 @@ msgstr ""
|
|
|
781
743
|
#. module: mail_gateway_whatsapp
|
|
782
744
|
#. odoo-python
|
|
783
745
|
#: code:addons/mail_gateway_whatsapp/models/mail_thread.py:0
|
|
784
|
-
#, python-format
|
|
785
746
|
msgid "Phone cannot be sanitized"
|
|
786
747
|
msgstr ""
|
|
787
748
|
|
|
@@ -871,7 +832,6 @@ msgstr ""
|
|
|
871
832
|
#. odoo-javascript
|
|
872
833
|
#: code:addons/mail_gateway_whatsapp/static/src/components/send_whatsapp_button/send_whatsapp_button.esm.js:0
|
|
873
834
|
#: model:ir.actions.act_window,name:mail_gateway_whatsapp.whatsapp_composer_act_window
|
|
874
|
-
#, python-format
|
|
875
835
|
msgid "Send Whatsapp Message"
|
|
876
836
|
msgstr ""
|
|
877
837
|
|
|
@@ -951,7 +911,6 @@ msgstr ""
|
|
|
951
911
|
#. module: mail_gateway_whatsapp
|
|
952
912
|
#. odoo-python
|
|
953
913
|
#: code:addons/mail_gateway_whatsapp/models/mail_gateway.py:0
|
|
954
|
-
#, python-format
|
|
955
914
|
msgid "Synchronization successfully."
|
|
956
915
|
msgstr ""
|
|
957
916
|
|
|
@@ -1010,7 +969,6 @@ msgstr ""
|
|
|
1010
969
|
#. module: mail_gateway_whatsapp
|
|
1011
970
|
#. odoo-python
|
|
1012
971
|
#: code:addons/mail_gateway_whatsapp/models/mail_gateway_whatsapp.py:0
|
|
1013
|
-
#, python-format
|
|
1014
972
|
msgid "Unable to send the whatsapp message"
|
|
1015
973
|
msgstr ""
|
|
1016
974
|
|
|
@@ -1042,20 +1000,9 @@ msgstr ""
|
|
|
1042
1000
|
#. module: mail_gateway_whatsapp
|
|
1043
1001
|
#. odoo-python
|
|
1044
1002
|
#: code:addons/mail_gateway_whatsapp/models/mail_gateway.py:0
|
|
1045
|
-
#, python-format
|
|
1046
1003
|
msgid "WathsApp Templates"
|
|
1047
1004
|
msgstr ""
|
|
1048
1005
|
|
|
1049
|
-
#. module: mail_gateway_whatsapp
|
|
1050
|
-
#: model:ir.model.fields,field_description:mail_gateway_whatsapp.field_res_partner__website_message_ids
|
|
1051
|
-
msgid "Website Messages"
|
|
1052
|
-
msgstr ""
|
|
1053
|
-
|
|
1054
|
-
#. module: mail_gateway_whatsapp
|
|
1055
|
-
#: model:ir.model.fields,help:mail_gateway_whatsapp.field_res_partner__website_message_ids
|
|
1056
|
-
msgid "Website communication history"
|
|
1057
|
-
msgstr ""
|
|
1058
|
-
|
|
1059
1006
|
#. module: mail_gateway_whatsapp
|
|
1060
1007
|
#: model:ir.model.fields.selection,name:mail_gateway_whatsapp.selection__mail_gateway__gateway_type__whatsapp
|
|
1061
1008
|
msgid "WhatsApp"
|
|
@@ -1064,7 +1011,6 @@ msgstr ""
|
|
|
1064
1011
|
#. module: mail_gateway_whatsapp
|
|
1065
1012
|
#. odoo-python
|
|
1066
1013
|
#: code:addons/mail_gateway_whatsapp/models/mail_gateway.py:0
|
|
1067
|
-
#, python-format
|
|
1068
1014
|
msgid "WhatsApp Account is required to import templates."
|
|
1069
1015
|
msgstr ""
|
|
1070
1016
|
|
|
@@ -1076,7 +1022,6 @@ msgstr ""
|
|
|
1076
1022
|
#. module: mail_gateway_whatsapp
|
|
1077
1023
|
#. odoo-javascript
|
|
1078
1024
|
#: code:addons/mail_gateway_whatsapp/static/src/components/send_whatsapp_button/send_whatsapp_button.xml:0
|
|
1079
|
-
#, python-format
|
|
1080
1025
|
msgid "Whatsapp"
|
|
1081
1026
|
msgstr ""
|
|
1082
1027
|
|
|
@@ -2,21 +2,18 @@
|
|
|
2
2
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
3
3
|
|
|
4
4
|
from odoo import models
|
|
5
|
-
from odoo.
|
|
5
|
+
from odoo.tools.misc import file_path
|
|
6
6
|
|
|
7
7
|
from odoo.addons.base.models.avatar_mixin import get_hsl_from_seed
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
class
|
|
11
|
-
|
|
12
|
-
_inherit = "mail.channel"
|
|
10
|
+
class DiscussChannel(models.Model):
|
|
11
|
+
_inherit = "discuss.channel"
|
|
13
12
|
|
|
14
13
|
def _generate_avatar_gateway(self):
|
|
15
14
|
if self.gateway_id.gateway_type == "whatsapp":
|
|
16
|
-
path =
|
|
17
|
-
|
|
18
|
-
)
|
|
19
|
-
with open(path, "r") as f:
|
|
15
|
+
path = file_path("mail_gateway_whatsapp/static/description/icon.svg")
|
|
16
|
+
with open(path) as f:
|
|
20
17
|
avatar = f.read()
|
|
21
18
|
|
|
22
19
|
bgcolor = get_hsl_from_seed(self.uuid)
|
|
@@ -17,7 +17,7 @@ class MailGateway(models.Model):
|
|
|
17
17
|
selection_add=[("whatsapp", "WhatsApp")], ondelete={"whatsapp": "cascade"}
|
|
18
18
|
)
|
|
19
19
|
whatsapp_from_phone = fields.Char()
|
|
20
|
-
whatsapp_version = fields.Char(default="
|
|
20
|
+
whatsapp_version = fields.Char(default="23.0")
|
|
21
21
|
whatsapp_account_id = fields.Char()
|
|
22
22
|
whatsapp_template_ids = fields.One2many("mail.whatsapp.template", "gateway_id")
|
|
23
23
|
whatsapp_template_count = fields.Integer(compute="_compute_whatsapp_template_count")
|
|
@@ -43,17 +43,12 @@ class MailGatewayWhatsappService(models.AbstractModel):
|
|
|
43
43
|
signature = request.httprequest.headers.get("x-hub-signature-256")
|
|
44
44
|
if not signature:
|
|
45
45
|
return False
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
).hexdigest()
|
|
53
|
-
!= signature
|
|
54
|
-
):
|
|
55
|
-
return False
|
|
56
|
-
return True
|
|
46
|
+
hex_dig = hmac.new(
|
|
47
|
+
bot_data["webhook_secret"].encode(),
|
|
48
|
+
request.httprequest.data,
|
|
49
|
+
hashlib.sha256,
|
|
50
|
+
).hexdigest()
|
|
51
|
+
return f"sha256={hex_dig}" == signature
|
|
57
52
|
|
|
58
53
|
def _get_channel_vals(self, gateway, token, update):
|
|
59
54
|
result = super()._get_channel_vals(gateway, token, update)
|
|
@@ -88,13 +83,10 @@ class MailGatewayWhatsappService(models.AbstractModel):
|
|
|
88
83
|
image_id = message.get(key).get("id")
|
|
89
84
|
if image_id:
|
|
90
85
|
image_info_request = requests.get(
|
|
91
|
-
"https://graph.facebook.com/
|
|
92
|
-
|
|
93
|
-
chat.gateway_id.whatsapp_version,
|
|
94
|
-
image_id,
|
|
95
|
-
),
|
|
86
|
+
f"https://graph.facebook.com/"
|
|
87
|
+
f"v{chat.gateway_id.whatsapp_version}/{image_id}",
|
|
96
88
|
headers={
|
|
97
|
-
"Authorization": "Bearer
|
|
89
|
+
"Authorization": f"Bearer {chat.gateway_id.token}",
|
|
98
90
|
},
|
|
99
91
|
timeout=10,
|
|
100
92
|
proxies=self._get_proxies(),
|
|
@@ -109,7 +101,7 @@ class MailGatewayWhatsappService(models.AbstractModel):
|
|
|
109
101
|
image_request = requests.get(
|
|
110
102
|
image_url,
|
|
111
103
|
headers={
|
|
112
|
-
"Authorization": "Bearer
|
|
104
|
+
"Authorization": f"Bearer {chat.gateway_id.token}",
|
|
113
105
|
},
|
|
114
106
|
timeout=10,
|
|
115
107
|
proxies=self._get_proxies(),
|
|
@@ -127,17 +119,19 @@ class MailGatewayWhatsappService(models.AbstractModel):
|
|
|
127
119
|
if message.get("location"):
|
|
128
120
|
body += (
|
|
129
121
|
'<a target="_blank" href="https://www.google.com/'
|
|
130
|
-
'maps/search/?api=1&query
|
|
131
|
-
|
|
132
|
-
message["location"]["latitude"],
|
|
133
|
-
message["location"]["longitude"],
|
|
134
|
-
)
|
|
122
|
+
f'maps/search/?api=1&query={message["location"]["latitude"]},'
|
|
123
|
+
f'{message["location"]["longitude"]}">Location</a>'
|
|
135
124
|
)
|
|
136
125
|
if message.get("contacts"):
|
|
137
126
|
pass
|
|
138
127
|
if len(body) > 0 or attachments:
|
|
139
128
|
author = self._get_author(chat.gateway_id, value)
|
|
140
|
-
|
|
129
|
+
if author._name == "mail.guest":
|
|
130
|
+
chat = chat.with_user(self.env.ref("base.public_user").id).with_context(
|
|
131
|
+
guest=author
|
|
132
|
+
)
|
|
133
|
+
# TODO: Check the sudo...
|
|
134
|
+
new_message = chat.sudo().message_post(
|
|
141
135
|
body=body,
|
|
142
136
|
author_id=author and author._name == "res.partner" and author.id,
|
|
143
137
|
gateway_type="whatsapp",
|
|
@@ -179,6 +173,13 @@ class MailGatewayWhatsappService(models.AbstractModel):
|
|
|
179
173
|
)
|
|
180
174
|
self._post_process_reply(related_message)
|
|
181
175
|
new_message.gateway_message_id = new_related_message
|
|
176
|
+
gateway_thread_data = new_message.sudo().gateway_thread_data
|
|
177
|
+
new_message._bus_send_store(
|
|
178
|
+
new_message,
|
|
179
|
+
{
|
|
180
|
+
"gateway_thread_data": gateway_thread_data,
|
|
181
|
+
},
|
|
182
|
+
)
|
|
182
183
|
|
|
183
184
|
def _send(
|
|
184
185
|
self,
|
|
@@ -208,13 +209,10 @@ class MailGatewayWhatsappService(models.AbstractModel):
|
|
|
208
209
|
)
|
|
209
210
|
|
|
210
211
|
response = requests.post(
|
|
211
|
-
"https://graph.facebook.com/
|
|
212
|
-
|
|
213
|
-
gateway.whatsapp_version,
|
|
214
|
-
gateway.whatsapp_from_phone,
|
|
215
|
-
),
|
|
212
|
+
f"https://graph.facebook.com/"
|
|
213
|
+
f"v{gateway.whatsapp_version}/{gateway.whatsapp_from_phone}/media",
|
|
216
214
|
headers={
|
|
217
|
-
"Authorization": "Bearer
|
|
215
|
+
"Authorization": f"Bearer {gateway.token}",
|
|
218
216
|
"content-type": m.content_type,
|
|
219
217
|
},
|
|
220
218
|
data=m,
|
|
@@ -223,12 +221,9 @@ class MailGatewayWhatsappService(models.AbstractModel):
|
|
|
223
221
|
)
|
|
224
222
|
response.raise_for_status()
|
|
225
223
|
response = requests.post(
|
|
226
|
-
"https://graph.facebook.com/
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
gateway.whatsapp_from_phone,
|
|
230
|
-
),
|
|
231
|
-
headers={"Authorization": "Bearer %s" % gateway.token},
|
|
224
|
+
f"https://graph.facebook.com/"
|
|
225
|
+
f"v{gateway.whatsapp_version}/{gateway.whatsapp_from_phone}/messages",
|
|
226
|
+
headers={"Authorization": f"Bearer {gateway.token}"},
|
|
232
227
|
json=self._send_payload(
|
|
233
228
|
record.gateway_channel_id,
|
|
234
229
|
media_id=response.json()["id"],
|
|
@@ -243,12 +238,9 @@ class MailGatewayWhatsappService(models.AbstractModel):
|
|
|
243
238
|
body = self._get_message_body(record)
|
|
244
239
|
if body:
|
|
245
240
|
response = requests.post(
|
|
246
|
-
"https://graph.facebook.com/
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
gateway.whatsapp_from_phone,
|
|
250
|
-
),
|
|
251
|
-
headers={"Authorization": "Bearer %s" % gateway.token},
|
|
241
|
+
f"https://graph.facebook.com/"
|
|
242
|
+
f"v{gateway.whatsapp_version}/{gateway.whatsapp_from_phone}/messages",
|
|
243
|
+
headers={"Authorization": f"Bearer {gateway.token}"},
|
|
252
244
|
json=self._send_payload(record.gateway_channel_id, body=body),
|
|
253
245
|
timeout=10,
|
|
254
246
|
proxies=self._get_proxies(),
|
|
@@ -264,9 +256,7 @@ class MailGatewayWhatsappService(models.AbstractModel):
|
|
|
264
256
|
_("Unable to send the whatsapp message")
|
|
265
257
|
) from exc
|
|
266
258
|
else:
|
|
267
|
-
_logger.warning(
|
|
268
|
-
"Issue sending message with id {}: {}".format(record.id, exc)
|
|
269
|
-
)
|
|
259
|
+
_logger.warning(f"Issue sending message with id {record.id}: {exc}")
|
|
270
260
|
record.sudo().write(
|
|
271
261
|
{"notification_status": "exception", "failure_reason": exc}
|
|
272
262
|
)
|
|
@@ -4,11 +4,8 @@
|
|
|
4
4
|
from odoo import _, models
|
|
5
5
|
from odoo.exceptions import UserError
|
|
6
6
|
|
|
7
|
-
from odoo.addons.phone_validation.tools import phone_validation
|
|
8
|
-
|
|
9
7
|
|
|
10
8
|
class MailThread(models.AbstractModel):
|
|
11
|
-
|
|
12
9
|
_inherit = "mail.thread"
|
|
13
10
|
|
|
14
11
|
def _get_whatsapp_channel_vals(self, token, gateway, partner):
|
|
@@ -22,12 +19,11 @@ class MailThread(models.AbstractModel):
|
|
|
22
19
|
return result
|
|
23
20
|
|
|
24
21
|
def _whatsapp_get_channel(self, field_name, gateway):
|
|
25
|
-
|
|
26
|
-
sanitize_res = phone_validation.phone_sanitize_numbers_w_record([phone], self)
|
|
27
|
-
sanitized_number = sanitize_res[phone].get("sanitized")
|
|
22
|
+
sanitized_number = self._phone_format(number=self[field_name])
|
|
28
23
|
if not sanitized_number:
|
|
29
24
|
raise UserError(_("Phone cannot be sanitized"))
|
|
30
|
-
|
|
25
|
+
# Avoid the plus sign prefix to match the whatsapp token
|
|
26
|
+
sanitized_number = sanitized_number.replace("+", "")
|
|
31
27
|
partner = self._whatsapp_get_partner()
|
|
32
28
|
if not self.env["res.partner.gateway.channel"].search(
|
|
33
29
|
[
|
|
@@ -9,8 +9,6 @@ from odoo import api, fields, models
|
|
|
9
9
|
from odoo.exceptions import UserError
|
|
10
10
|
from odoo.tools import ustr
|
|
11
11
|
|
|
12
|
-
from odoo.addons.http_routing.models.ir_http import slugify
|
|
13
|
-
|
|
14
12
|
from ..tools.const import supported_languages
|
|
15
13
|
from .mail_gateway import BASE_URL
|
|
16
14
|
|
|
@@ -79,7 +77,7 @@ class MailWhatsAppTemplate(models.Model):
|
|
|
79
77
|
template.state == "draft" and not template.template_uid
|
|
80
78
|
):
|
|
81
79
|
template.template_name = re.sub(
|
|
82
|
-
r"\W+", "_",
|
|
80
|
+
r"\W+", "_", self.env["ir.http"]._slugify(template.name or "")
|
|
83
81
|
)
|
|
84
82
|
|
|
85
83
|
def button_back2draft(self):
|
|
@@ -96,7 +94,7 @@ class MailWhatsAppTemplate(models.Model):
|
|
|
96
94
|
payload = self._prepare_values_to_export()
|
|
97
95
|
response = requests.post(
|
|
98
96
|
template_url,
|
|
99
|
-
headers={"Authorization": "Bearer
|
|
97
|
+
headers={"Authorization": f"Bearer {gateway.token}"},
|
|
100
98
|
json=payload,
|
|
101
99
|
timeout=10,
|
|
102
100
|
)
|
|
@@ -154,7 +152,7 @@ class MailWhatsAppTemplate(models.Model):
|
|
|
154
152
|
try:
|
|
155
153
|
response = requests.get(
|
|
156
154
|
template_url,
|
|
157
|
-
headers={"Authorization": "Bearer
|
|
155
|
+
headers={"Authorization": f"Bearer {gateway.token}"},
|
|
158
156
|
timeout=10,
|
|
159
157
|
)
|
|
160
158
|
response.raise_for_status()
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
## First steps
|
|
2
|
+
|
|
3
|
+
You need to create a WhatsApp Business Account (WABA), a Meta App and
|
|
4
|
+
define a phone number. You can follow this
|
|
5
|
+
[steps](https://developers.facebook.com/micro_site/url/?click_from_context_menu=true&country=ES&destination=https%3A%2F%2Fwww.facebook.com%2Fbusiness%2Fhelp%2F2087193751603668&event_type=click&last_nav_impression_id=0m3TRxrxOlly1eRmB&max_percent_page_viewed=22&max_viewport_height_px=1326&max_viewport_width_px=2560&orig_http_referrer=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fwhatsapp%2Fcloud-api%2Fget-started-for-bsps%3Flocale%3Den_US&orig_request_uri=https%3A%2F%2Fdevelopers.facebook.com%2Fajax%2Fpagelet%2Fgeneric.php%2FDeveloperNotificationsPayloadPagelet%3Ffb_dtsg_ag%3D--sanitized--%26data%3D%257B%2522businessUserID%2522%253Anull%252C%2522cursor%2522%253Anull%252C%2522length%2522%253A15%252C%2522clientRequestID%2522%253A%2522js_k6%2522%257D%26__usid%3D6-Trd7hi4itpm%253APrd7ifiub2tvy%253A0-Ard7g9twdm0p1-RV%253D6%253AF%253D%26locale%3Den_US%26jazoest%3D24920®ion=emea&scrolled=false&session_id=1jLoVJNU6iVMaw3ml&site=developers).
|
|
6
|
+
|
|
7
|
+
If you create a test Business Account, passwords will change every 24
|
|
8
|
+
hours.
|
|
9
|
+
|
|
10
|
+
In order to make the webhook accessible, the system must be public.
|
|
11
|
+
|
|
12
|
+
## Configure the gateway
|
|
13
|
+
|
|
14
|
+
Once you have created the Meta App, you need to add the gateway and
|
|
15
|
+
webhook. In order to make it you must follow this steps:
|
|
16
|
+
|
|
17
|
+
- Access Settings \> Emails \> Mail Gateway
|
|
18
|
+
- Create a Gateway of type WhatsApp
|
|
19
|
+
|
|
20
|
+
> - Use the Meta App authentication key as Token field
|
|
21
|
+
> - Use the Meta App Phone Number ID as Whatsapp from Phone field
|
|
22
|
+
> - Use the Meta Account Business ID as Whatsapp account field (only if
|
|
23
|
+
> you need sync templates)
|
|
24
|
+
> - Write your own Webhook key
|
|
25
|
+
> - Use the Application Secret Key on Whatsapp Security Key. It will be
|
|
26
|
+
> used in order to validate the data
|
|
27
|
+
> - Press the Integrate Webhook Key. In this case, it will not integrate
|
|
28
|
+
> it, we need to make it manually
|
|
29
|
+
> - Copy the webhook URL
|
|
30
|
+
|
|
31
|
+
- Access [Facebook Apps website](https://developers.facebook.com/apps/)
|
|
32
|
+
- Access your App then Whatsapp \> Configuration
|
|
33
|
+
- Create your webhook using your URL and put the Whatsapp Security Key
|
|
34
|
+
as validation Key
|
|
35
|
+
- Administer the Webhook and activate the messages webhook
|
|
@@ -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>)
|