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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
5
5
|
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
|
|
6
|
-
<title>
|
|
6
|
+
<title>README.rst</title>
|
|
7
7
|
<style type="text/css">
|
|
8
8
|
|
|
9
9
|
/*
|
|
@@ -360,19 +360,24 @@ ul.auto-toc {
|
|
|
360
360
|
</style>
|
|
361
361
|
</head>
|
|
362
362
|
<body>
|
|
363
|
-
<div class="document"
|
|
364
|
-
<h1 class="title">Mail Whatsapp Gateway</h1>
|
|
363
|
+
<div class="document">
|
|
365
364
|
|
|
365
|
+
|
|
366
|
+
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
|
|
367
|
+
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
|
|
368
|
+
</a>
|
|
369
|
+
<div class="section" id="mail-whatsapp-gateway">
|
|
370
|
+
<h1>Mail Whatsapp Gateway</h1>
|
|
366
371
|
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
367
372
|
!! This file is generated by oca-gen-addon-readme !!
|
|
368
373
|
!! changes will be overwritten. !!
|
|
369
374
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
370
|
-
!! source digest: sha256:
|
|
375
|
+
!! source digest: sha256:a7bdf09868559f4a3a765f239ee66aec81889e5a9f1a29249cfd54f418a52143
|
|
371
376
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
|
372
|
-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/
|
|
377
|
+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/social/tree/18.0/mail_gateway_whatsapp"><img alt="OCA/social" src="https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/social-18-0/social-18-0-mail_gateway_whatsapp"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/social&target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
|
373
378
|
<p>This module allows to respond whatsapp chats.</p>
|
|
374
|
-
<p>This way, a group of users can respond customers or any other set
|
|
375
|
-
|
|
379
|
+
<p>This way, a group of users can respond customers or any other set of
|
|
380
|
+
partners in an integrated way.</p>
|
|
376
381
|
<p><strong>Table of contents</strong></p>
|
|
377
382
|
<div class="contents local topic" id="contents">
|
|
378
383
|
<ul class="simple">
|
|
@@ -394,76 +399,84 @@ of partners in an integrated way.</p>
|
|
|
394
399
|
</ul>
|
|
395
400
|
</div>
|
|
396
401
|
<div class="section" id="configuration">
|
|
397
|
-
<
|
|
402
|
+
<h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
|
|
398
403
|
<div class="section" id="first-steps">
|
|
399
|
-
<
|
|
400
|
-
<p>You need to create a WhatsApp Business Account (WABA), a Meta App and
|
|
401
|
-
You can follow this
|
|
402
|
-
<
|
|
404
|
+
<h3><a class="toc-backref" href="#toc-entry-2">First steps</a></h3>
|
|
405
|
+
<p>You need to create a WhatsApp Business Account (WABA), a Meta App and
|
|
406
|
+
define a phone number. You can follow this
|
|
407
|
+
<a class="reference external" href="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&region=emea&scrolled=false&session_id=1jLoVJNU6iVMaw3ml&site=developers">steps</a>.</p>
|
|
408
|
+
<p>If you create a test Business Account, passwords will change every 24
|
|
409
|
+
hours.</p>
|
|
403
410
|
<p>In order to make the webhook accessible, the system must be public.</p>
|
|
404
411
|
</div>
|
|
405
412
|
<div class="section" id="configure-the-gateway">
|
|
406
|
-
<
|
|
407
|
-
<p>Once you have created the Meta App, you need to add the gateway and
|
|
408
|
-
In order to make it you must follow this steps:</p>
|
|
413
|
+
<h3><a class="toc-backref" href="#toc-entry-3">Configure the gateway</a></h3>
|
|
414
|
+
<p>Once you have created the Meta App, you need to add the gateway and
|
|
415
|
+
webhook. In order to make it you must follow this steps:</p>
|
|
409
416
|
<ul class="simple">
|
|
410
|
-
<li>Access
|
|
411
|
-
<li>Create a Gateway of type
|
|
417
|
+
<li>Access Settings > Emails > Mail Gateway</li>
|
|
418
|
+
<li>Create a Gateway of type WhatsApp</li>
|
|
412
419
|
</ul>
|
|
420
|
+
<!-- -->
|
|
413
421
|
<blockquote>
|
|
414
422
|
<ul class="simple">
|
|
415
|
-
<li>Use the Meta App authentication key as
|
|
416
|
-
<li>Use the Meta App Phone Number ID as
|
|
417
|
-
<li>Use the Meta Account Business ID as
|
|
418
|
-
|
|
419
|
-
<li>
|
|
420
|
-
<li>
|
|
423
|
+
<li>Use the Meta App authentication key as Token field</li>
|
|
424
|
+
<li>Use the Meta App Phone Number ID as Whatsapp from Phone field</li>
|
|
425
|
+
<li>Use the Meta Account Business ID as Whatsapp account field (only if
|
|
426
|
+
you need sync templates)</li>
|
|
427
|
+
<li>Write your own Webhook key</li>
|
|
428
|
+
<li>Use the Application Secret Key on Whatsapp Security Key. It will be
|
|
429
|
+
used in order to validate the data</li>
|
|
430
|
+
<li>Press the Integrate Webhook Key. In this case, it will not
|
|
431
|
+
integrate it, we need to make it manually</li>
|
|
421
432
|
<li>Copy the webhook URL</li>
|
|
422
433
|
</ul>
|
|
423
434
|
</blockquote>
|
|
424
435
|
<ul class="simple">
|
|
425
|
-
<li>Access <a class="reference external" href="https://developers.facebook.com/apps/">Facebook Apps
|
|
426
|
-
|
|
427
|
-
<li>
|
|
436
|
+
<li>Access <a class="reference external" href="https://developers.facebook.com/apps/">Facebook Apps
|
|
437
|
+
website</a></li>
|
|
438
|
+
<li>Access your App then Whatsapp > Configuration</li>
|
|
439
|
+
<li>Create your webhook using your URL and put the Whatsapp Security Key
|
|
440
|
+
as validation Key</li>
|
|
428
441
|
<li>Administer the Webhook and activate the messages webhook</li>
|
|
429
442
|
</ul>
|
|
430
443
|
</div>
|
|
431
444
|
</div>
|
|
432
445
|
<div class="section" id="usage">
|
|
433
|
-
<
|
|
446
|
+
<h2><a class="toc-backref" href="#toc-entry-4">Usage</a></h2>
|
|
434
447
|
<ol class="arabic simple">
|
|
435
|
-
<li>Access
|
|
448
|
+
<li>Access Gateway</li>
|
|
436
449
|
<li>Wait until someone starts a conversation.</li>
|
|
437
450
|
<li>Now you will be able to respond and receive messages to this person.</li>
|
|
438
451
|
</ol>
|
|
439
452
|
</div>
|
|
440
453
|
<div class="section" id="known-issues-roadmap">
|
|
441
|
-
<
|
|
454
|
+
<h2><a class="toc-backref" href="#toc-entry-5">Known issues / Roadmap</a></h2>
|
|
442
455
|
<p><strong>WhatsApp templates</strong></p>
|
|
443
456
|
<ul class="simple">
|
|
444
|
-
<li>Add support for
|
|
445
|
-
<li>Add support for
|
|
457
|
+
<li>Add support for Variables</li>
|
|
458
|
+
<li>Add support for Buttons</li>
|
|
446
459
|
</ul>
|
|
447
460
|
</div>
|
|
448
461
|
<div class="section" id="bug-tracker">
|
|
449
|
-
<
|
|
462
|
+
<h2><a class="toc-backref" href="#toc-entry-6">Bug Tracker</a></h2>
|
|
450
463
|
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/social/issues">GitHub Issues</a>.
|
|
451
464
|
In case of trouble, please check there if your issue has already been reported.
|
|
452
465
|
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
|
453
|
-
<a class="reference external" href="https://github.com/OCA/social/issues/new?body=module:%20mail_gateway_whatsapp%0Aversion:%
|
|
466
|
+
<a class="reference external" href="https://github.com/OCA/social/issues/new?body=module:%20mail_gateway_whatsapp%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
|
454
467
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
|
455
468
|
</div>
|
|
456
469
|
<div class="section" id="credits">
|
|
457
|
-
<
|
|
470
|
+
<h2><a class="toc-backref" href="#toc-entry-7">Credits</a></h2>
|
|
458
471
|
<div class="section" id="authors">
|
|
459
|
-
<
|
|
472
|
+
<h3><a class="toc-backref" href="#toc-entry-8">Authors</a></h3>
|
|
460
473
|
<ul class="simple">
|
|
461
474
|
<li>Creu Blanca</li>
|
|
462
475
|
<li>Dixmit</li>
|
|
463
476
|
</ul>
|
|
464
477
|
</div>
|
|
465
478
|
<div class="section" id="contributors">
|
|
466
|
-
<
|
|
479
|
+
<h3><a class="toc-backref" href="#toc-entry-9">Contributors</a></h3>
|
|
467
480
|
<ul>
|
|
468
481
|
<li><p class="first">Olga Marco <<a class="reference external" href="mailto:olga.marco@creublanca.es">olga.marco@creublanca.es</a>></p>
|
|
469
482
|
</li>
|
|
@@ -479,11 +492,12 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
|
|
479
492
|
</ul>
|
|
480
493
|
</div>
|
|
481
494
|
<div class="section" id="other-credits">
|
|
482
|
-
<
|
|
483
|
-
<p>This work has been funded by AEOdoo (Asociación Española de Odoo -
|
|
495
|
+
<h3><a class="toc-backref" href="#toc-entry-10">Other credits</a></h3>
|
|
496
|
+
<p>This work has been funded by AEOdoo (Asociación Española de Odoo -
|
|
497
|
+
<a class="reference external" href="https://www.aeodoo.org">https://www.aeodoo.org</a>)</p>
|
|
484
498
|
</div>
|
|
485
499
|
<div class="section" id="maintainers">
|
|
486
|
-
<
|
|
500
|
+
<h3><a class="toc-backref" href="#toc-entry-11">Maintainers</a></h3>
|
|
487
501
|
<p>This module is maintained by the OCA.</p>
|
|
488
502
|
<a class="reference external image-reference" href="https://odoo-community.org">
|
|
489
503
|
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
|
|
@@ -491,10 +505,11 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
|
|
491
505
|
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
|
492
506
|
mission is to support the collaborative development of Odoo features and
|
|
493
507
|
promote its widespread use.</p>
|
|
494
|
-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/social/tree/
|
|
508
|
+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/social/tree/18.0/mail_gateway_whatsapp">OCA/social</a> project on GitHub.</p>
|
|
495
509
|
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
|
496
510
|
</div>
|
|
497
511
|
</div>
|
|
498
512
|
</div>
|
|
513
|
+
</div>
|
|
499
514
|
</body>
|
|
500
515
|
</html>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
2
|
<templates xml:space="preserve">
|
|
3
|
-
<t t-inherit="mail.
|
|
3
|
+
<t t-inherit="mail.Message.notification" t-inherit-mode="extension">
|
|
4
4
|
<xpath expr="//div" position="after">
|
|
5
5
|
<i
|
|
6
6
|
class="fa fa-whatsapp text-info"
|
|
7
|
-
t-if="
|
|
7
|
+
t-if="message.gateway_type === 'whatsapp' and message.notifications.length === 0"
|
|
8
8
|
/>
|
|
9
9
|
</xpath>
|
|
10
10
|
</t>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {Message} from "@mail/core/common/message";
|
|
2
|
+
import {patch} from "@web/core/utils/patch";
|
|
3
|
+
import {url} from "@web/core/utils/urls";
|
|
4
|
+
|
|
5
|
+
patch(Message.prototype, {
|
|
6
|
+
get authorAvatarUrl() {
|
|
7
|
+
if (
|
|
8
|
+
this.message.gateway_type &&
|
|
9
|
+
this.message.gateway_type.includes("whatsapp") &&
|
|
10
|
+
!["partner", "guest"].includes(this.message.author?.type)
|
|
11
|
+
) {
|
|
12
|
+
return url("/mail_gateway_whatsapp/static/description/icon.png");
|
|
13
|
+
}
|
|
14
|
+
return super.authorAvatarUrl;
|
|
15
|
+
},
|
|
16
|
+
});
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
/** @odoo-module **/
|
|
2
|
-
|
|
3
1
|
import {PhoneField} from "@web/views/fields/phone/phone_field";
|
|
4
|
-
import {SendWhatsappButton} from "
|
|
2
|
+
import {SendWhatsappButton} from "../send_whatsapp_button/send_whatsapp_button.esm";
|
|
5
3
|
import {patch} from "@web/core/utils/patch";
|
|
6
|
-
|
|
4
|
+
|
|
5
|
+
patch(PhoneField, {
|
|
7
6
|
components: {
|
|
8
7
|
...PhoneField.components,
|
|
9
8
|
SendWhatsappButton,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
<t t-inherit="web.PhoneField" t-inherit-mode="extension">
|
|
5
5
|
<xpath expr="//div[hasclass('o_phone_content')]//a" position="after">
|
|
6
|
-
<t t-if="props.enableButton and props.
|
|
6
|
+
<t t-if="props.enableButton and props.record.data[props.name].length > 0">
|
|
7
7
|
<SendWhatsappButton t-props="props" />
|
|
8
8
|
</t>
|
|
9
9
|
</xpath>
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
<t t-inherit="web.FormPhoneField" t-inherit-mode="extension">
|
|
13
13
|
<xpath expr="//div[hasclass('o_phone_content')]" position="inside">
|
|
14
|
-
<t t-if="props.enableButton and props.
|
|
14
|
+
<t t-if="props.enableButton and props.record.data[props.name].length > 0">
|
|
15
15
|
<SendWhatsappButton t-props="props" />
|
|
16
16
|
</t>
|
|
17
17
|
</xpath>
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
/** @odoo-module **/
|
|
2
|
-
|
|
3
1
|
import {useService} from "@web/core/utils/hooks";
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import {_t} from "@web/core/l10n/translation";
|
|
3
|
+
import {user} from "@web/core/user";
|
|
4
|
+
import {Component, status} from "@odoo/owl";
|
|
6
5
|
|
|
7
6
|
export class SendWhatsappButton extends Component {
|
|
8
7
|
setup() {
|
|
9
8
|
this.action = useService("action");
|
|
10
|
-
this.
|
|
11
|
-
this.title = this.env._t("Send Whatsapp Message");
|
|
9
|
+
this.title = _t("Send Whatsapp Message");
|
|
12
10
|
}
|
|
13
11
|
get phoneHref() {
|
|
14
|
-
return "sms:" + this.props.
|
|
12
|
+
return "sms:" + this.props.record.data[this.props.name].replace(/\s+/g, "");
|
|
15
13
|
}
|
|
16
14
|
async onClick() {
|
|
17
15
|
await this.props.record.save();
|
|
@@ -23,7 +21,7 @@ export class SendWhatsappButton extends Component {
|
|
|
23
21
|
res_model: "whatsapp.composer",
|
|
24
22
|
views: [[false, "form"]],
|
|
25
23
|
context: {
|
|
26
|
-
...
|
|
24
|
+
...user.context,
|
|
27
25
|
default_res_model: this.props.record.resModel,
|
|
28
26
|
default_res_id: this.props.record.resId,
|
|
29
27
|
default_number_field_name: this.props.name,
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
2
|
<templates xml:space="preserve">
|
|
3
3
|
|
|
4
|
-
<t t-name="mail_gateway_whatsapp.SendWhatsappButton"
|
|
4
|
+
<t t-name="mail_gateway_whatsapp.SendWhatsappButton">
|
|
5
5
|
<a
|
|
6
6
|
t-att-title="title"
|
|
7
7
|
t-att-href="phoneHref"
|
|
8
8
|
t-on-click.prevent.stop="onClick"
|
|
9
9
|
class="ms-3 d-inline-flex align-items-center o_field_phone_whatsapp"
|
|
10
|
-
|
|
10
|
+
>
|
|
11
|
+
<i class="fa fa-whatsapp" />
|
|
12
|
+
<small class="fw-bold ms-1">Whatsapp</small>
|
|
13
|
+
</a>
|
|
11
14
|
</t>
|
|
12
15
|
|
|
13
16
|
</templates>
|
|
@@ -157,16 +157,14 @@ class TestMailGatewayWhatsApp(MailGatewayTestCase):
|
|
|
157
157
|
data = json.dumps(message)
|
|
158
158
|
headers_dict = {"Content-Type": "application/json"}
|
|
159
159
|
if headers:
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
).hexdigest()
|
|
167
|
-
)
|
|
160
|
+
hex_dig = hmac.new(
|
|
161
|
+
self.gateway.webhook_secret.encode(),
|
|
162
|
+
data.encode(),
|
|
163
|
+
hashlib.sha256,
|
|
164
|
+
).hexdigest()
|
|
165
|
+
headers_dict["x-hub-signature-256"] = f"sha256={hex_dig}"
|
|
168
166
|
self.url_open(
|
|
169
|
-
"/gateway/{}/{}/update"
|
|
167
|
+
f"/gateway/{self.gateway.gateway_type}/{webhook}/update",
|
|
170
168
|
data=data,
|
|
171
169
|
headers=headers_dict,
|
|
172
170
|
)
|
|
@@ -176,7 +174,9 @@ class TestMailGatewayWhatsApp(MailGatewayTestCase):
|
|
|
176
174
|
self.gateway.set_webhook()
|
|
177
175
|
self.integrate_webhook()
|
|
178
176
|
self.set_message(message, self.webhook)
|
|
179
|
-
chat = self.env["
|
|
177
|
+
chat = self.env["discuss.channel"].search(
|
|
178
|
+
[("gateway_id", "=", self.gateway.id)]
|
|
179
|
+
)
|
|
180
180
|
self.assertTrue(chat)
|
|
181
181
|
self.assertTrue(chat.message_ids)
|
|
182
182
|
return chat.message_ids
|
|
@@ -207,38 +207,38 @@ class TestMailGatewayWhatsApp(MailGatewayTestCase):
|
|
|
207
207
|
get_mock.return_value = GetImageResponse()
|
|
208
208
|
self.receive_message(self.message_02)
|
|
209
209
|
|
|
210
|
+
@mute_logger("odoo.addons.mail_gateway.controllers.gateway")
|
|
210
211
|
def test_post_no_signature_no_message(self):
|
|
211
212
|
self.gateway.webhook_key = self.webhook
|
|
212
213
|
self.gateway.set_webhook()
|
|
213
214
|
self.integrate_webhook()
|
|
214
215
|
self.set_message(self.message_01, self.webhook, False)
|
|
215
216
|
self.assertFalse(
|
|
216
|
-
self.env["
|
|
217
|
+
self.env["discuss.channel"].search([("gateway_id", "=", self.gateway.id)])
|
|
217
218
|
)
|
|
218
219
|
|
|
220
|
+
@mute_logger("odoo.addons.mail_gateway.controllers.gateway")
|
|
219
221
|
def test_post_wrong_signature_no_message(self):
|
|
220
222
|
self.gateway.webhook_key = self.webhook
|
|
221
223
|
self.gateway.set_webhook()
|
|
222
224
|
self.integrate_webhook()
|
|
223
225
|
data = json.dumps(self.message_01)
|
|
226
|
+
hex_dig = hmac.new(
|
|
227
|
+
self.gateway.webhook_secret.encode(),
|
|
228
|
+
data.encode(),
|
|
229
|
+
hashlib.sha256,
|
|
230
|
+
).hexdigest()
|
|
224
231
|
headers = {
|
|
225
232
|
"Content-Type": "application/json",
|
|
226
|
-
"x-hub-signature-256":
|
|
227
|
-
"sha256=1234%s"
|
|
228
|
-
% hmac.new(
|
|
229
|
-
self.gateway.webhook_secret.encode(),
|
|
230
|
-
data.encode(),
|
|
231
|
-
hashlib.sha256,
|
|
232
|
-
).hexdigest()
|
|
233
|
-
),
|
|
233
|
+
"x-hub-signature-256": f"sha256=1234{hex_dig}",
|
|
234
234
|
}
|
|
235
235
|
self.url_open(
|
|
236
|
-
"/gateway/{
|
|
236
|
+
f"/gateway/{self.gateway.gateway_type}/{self.webhook}/update",
|
|
237
237
|
data=data,
|
|
238
238
|
headers=headers,
|
|
239
239
|
)
|
|
240
240
|
self.assertFalse(
|
|
241
|
-
self.env["
|
|
241
|
+
self.env["discuss.channel"].search([("gateway_id", "=", self.gateway.id)])
|
|
242
242
|
)
|
|
243
243
|
|
|
244
244
|
def test_send_image(self):
|
|
@@ -254,7 +254,7 @@ class TestMailGatewayWhatsApp(MailGatewayTestCase):
|
|
|
254
254
|
}
|
|
255
255
|
)
|
|
256
256
|
composer.action_view_whatsapp()
|
|
257
|
-
channel = self.env["
|
|
257
|
+
channel = self.env["discuss.channel"].search(
|
|
258
258
|
[("gateway_id", "=", self.gateway.id)]
|
|
259
259
|
)
|
|
260
260
|
|
|
@@ -281,7 +281,7 @@ class TestMailGatewayWhatsApp(MailGatewayTestCase):
|
|
|
281
281
|
}
|
|
282
282
|
)
|
|
283
283
|
composer.action_view_whatsapp()
|
|
284
|
-
channel = self.env["
|
|
284
|
+
channel = self.env["discuss.channel"].search(
|
|
285
285
|
[("gateway_id", "=", self.gateway.id)]
|
|
286
286
|
)
|
|
287
287
|
with mute_logger(
|
|
@@ -323,9 +323,10 @@ class TestMailGatewayWhatsApp(MailGatewayTestCase):
|
|
|
323
323
|
("model", "=", channel._name),
|
|
324
324
|
("res_id", "=", channel.id),
|
|
325
325
|
]
|
|
326
|
-
with
|
|
327
|
-
"
|
|
328
|
-
|
|
326
|
+
with (
|
|
327
|
+
RecordCapturer(self.env["mail.message"], message_domain) as capture,
|
|
328
|
+
patch("requests.post") as post_mock,
|
|
329
|
+
):
|
|
329
330
|
post_mock.return_value = MagicMock()
|
|
330
331
|
composer.action_send_whatsapp()
|
|
331
332
|
self.assertEqual(len(capture.records), 1)
|
|
@@ -345,9 +346,10 @@ class TestMailGatewayWhatsApp(MailGatewayTestCase):
|
|
|
345
346
|
("model", "=", channel._name),
|
|
346
347
|
("res_id", "=", channel.id),
|
|
347
348
|
]
|
|
348
|
-
with
|
|
349
|
-
"
|
|
350
|
-
|
|
349
|
+
with (
|
|
350
|
+
RecordCapturer(self.env["mail.message"], message_domain) as capture,
|
|
351
|
+
patch("requests.post") as post_mock,
|
|
352
|
+
):
|
|
351
353
|
post_mock.return_value = MagicMock()
|
|
352
354
|
composer.action_send_whatsapp()
|
|
353
355
|
self.assertEqual(len(capture.records), 1)
|
|
@@ -366,7 +368,7 @@ class TestMailGatewayWhatsApp(MailGatewayTestCase):
|
|
|
366
368
|
}
|
|
367
369
|
)
|
|
368
370
|
composer.action_view_whatsapp()
|
|
369
|
-
channel = self.env["
|
|
371
|
+
channel = self.env["discuss.channel"].search(
|
|
370
372
|
[("gateway_id", "=", self.gateway.id)]
|
|
371
373
|
)
|
|
372
374
|
self.assertTrue(channel)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates/supported-languages # noqa:
|
|
1
|
+
# https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates/supported-languages # noqa: B501 E501
|
|
2
2
|
# res.lang not matching with supported languages(iso codes)
|
|
3
3
|
supported_languages = [
|
|
4
4
|
("af", "Afrikaans"),
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
type="object"
|
|
13
13
|
name="button_import_whatsapp_template"
|
|
14
14
|
string="Download Templates"
|
|
15
|
-
|
|
15
|
+
invisible="gateway_type != 'whatsapp'"
|
|
16
16
|
icon="fa-download"
|
|
17
17
|
/>
|
|
18
18
|
</xpath>
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
<button
|
|
21
21
|
type="action"
|
|
22
22
|
name="%(mail_gateway_whatsapp.action_mail_whatsapp_template_gateway)d"
|
|
23
|
-
|
|
23
|
+
invisible="gateway_type != 'whatsapp'"
|
|
24
24
|
class="oe_stat_button"
|
|
25
25
|
icon="fa-whatsapp"
|
|
26
26
|
>
|
|
@@ -34,45 +34,42 @@
|
|
|
34
34
|
<field name="webhook_user_id" position="after">
|
|
35
35
|
<field
|
|
36
36
|
name="whatsapp_account_id"
|
|
37
|
-
|
|
37
|
+
invisible="gateway_type != 'whatsapp'"
|
|
38
38
|
/>
|
|
39
39
|
<field
|
|
40
40
|
name="whatsapp_security_key"
|
|
41
|
-
|
|
41
|
+
invisible="gateway_type != 'whatsapp'"
|
|
42
42
|
/>
|
|
43
43
|
<field
|
|
44
44
|
name="whatsapp_from_phone"
|
|
45
|
-
|
|
46
|
-
/>
|
|
47
|
-
<field
|
|
48
|
-
name="whatsapp_version"
|
|
49
|
-
attrs="{'invisible': [('gateway_type', '!=', 'whatsapp')]}"
|
|
45
|
+
invisible="gateway_type != 'whatsapp'"
|
|
50
46
|
/>
|
|
47
|
+
<field name="whatsapp_version" invisible="gateway_type != 'whatsapp'" />
|
|
51
48
|
</field>
|
|
52
49
|
<notebook position="inside">
|
|
53
50
|
<page
|
|
54
51
|
name="whatsapp"
|
|
55
52
|
string="Whatsapp configuration info"
|
|
56
|
-
|
|
53
|
+
invisible="gateway_type != 'whatsapp'"
|
|
57
54
|
>
|
|
58
55
|
<div>
|
|
59
56
|
<h2>First steps</h2>
|
|
60
57
|
<span>Define the values of the fields <b>Webhook Key</b> and <b
|
|
61
|
-
|
|
58
|
+
>Whatsapp Security Key</b>.
|
|
62
59
|
You should set some random value of your choice for this fields.
|
|
63
60
|
Ensure that facebook will be able to comunicate with your server.</span>
|
|
64
61
|
<h2>Creating the Application from meta developer</h2>
|
|
65
62
|
<ol>
|
|
66
63
|
<li>Access
|
|
67
64
|
<a
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
href="https://developers.facebook.com/apps/?show_reminder=true"
|
|
66
|
+
target="_blank"
|
|
67
|
+
rel="noopener noreferrer"
|
|
68
|
+
>
|
|
72
69
|
Meta developer platform</a>.</li>
|
|
73
70
|
<li>Create a new application.</li>
|
|
74
71
|
<li>Select the <b>Other</b> option, then <b
|
|
75
|
-
|
|
72
|
+
>Business</b> in order to create Whatsapp manager</li>
|
|
76
73
|
<li>Select a name and create it</li>
|
|
77
74
|
<li
|
|
78
75
|
>Select the Whatsapp API on the products of the application</li>
|
|
@@ -80,27 +77,27 @@
|
|
|
80
77
|
<li>Go to <b>Whatsapp / API Configuration</b> menú.</li>
|
|
81
78
|
<li>Add a new number.</li>
|
|
82
79
|
<li>Copy the phone identification number to the field <b
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
80
|
+
>Whastapp From phone</b> field.</li>
|
|
81
|
+
<li>Access the menu <b
|
|
82
|
+
>Configuration / Basic information</b>.</li>
|
|
83
|
+
<li
|
|
87
84
|
>Show the secret key of the application and copy it to the <b
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
85
|
+
>Webhook secret</b> field.</li>
|
|
86
|
+
<li>Access the menu <b
|
|
87
|
+
>Configuration / Advanced Options</b>.</li>
|
|
88
|
+
<li>Copy the API Version on the <b
|
|
89
|
+
>Whastapp Version</b> field.</li>
|
|
93
90
|
</ol>
|
|
94
91
|
<h2>Creating a permanent token</h2>
|
|
95
92
|
<ol>
|
|
96
93
|
<li>Access your <a
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
94
|
+
href="https://business.facebook.com/"
|
|
95
|
+
target="_blank"
|
|
96
|
+
rel="noopener noreferrer"
|
|
97
|
+
>meta business site.</a></li>
|
|
101
98
|
<li>Access your business settings menu</li>
|
|
102
99
|
<li>Go to <b
|
|
103
|
-
|
|
100
|
+
>Users / System Users</b> and create a new one with administrator</li>
|
|
104
101
|
<li
|
|
105
102
|
>Once it is created, Generate a new token related to the created app with no expiry and give access to all whatsapp permissions.</li>
|
|
106
103
|
<li>Copy the token value to token field in this page.</li>
|
|
@@ -111,11 +108,11 @@
|
|
|
111
108
|
<li>Press the button Integrate webhook.</li>
|
|
112
109
|
<li
|
|
113
110
|
>On Facebook Develpment, return to the app menu and go to <b
|
|
114
|
-
|
|
111
|
+
>Whatsapp / Configuration</b>.</li>
|
|
115
112
|
<li>Click on <b>Edit Button</b> on the webhook area.</li>
|
|
116
113
|
<li>On the wizard, fill the URL field with <b
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
>Webhook URL</b> field of the gateway. For the verification identifier, use the <b
|
|
115
|
+
>Whatsapp Security Key</b> field.</li>
|
|
119
116
|
<li>Verify and save the wizard.</li>
|
|
120
117
|
<li
|
|
121
118
|
>If no error is raised, refresh this gateway data, and you should see that it is integrated.
|
|
@@ -123,7 +120,6 @@
|
|
|
123
120
|
If an error is raised, check that the fields are filled properly and that facebook server is able to access your server.</li>
|
|
124
121
|
</ol>
|
|
125
122
|
</div>
|
|
126
|
-
|
|
127
123
|
</page>
|
|
128
124
|
</notebook>
|
|
129
125
|
</field>
|