Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

Whatsapp Api and share link

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
server_actionsodoo16features
2 Odpowiedzi
6029 Widoki
Awatar
Kamran Lalehparvar

Hello All

i have create an action in server action to open whatsapp API and send a message with share link here is my code:

if not record.partner_id.mobile:
raise UserError('No mobile number found for the selected partner.')
else:
# create message
message = "Hello %s,Your quotation %s amounting in %s %s is ready for review. Here's the link to view it: https://erp.gyc.com/mail/view?model=sale.order&res_id=%s&access_token=%s Regards," % (record.partner_id.name, record.name, record.amount_total, record.currency_id.name, record.id, record.access_token)

# create action
action = {
'name': "WhatsApp",
'type': 'ir.actions.act_url',
'url': "https://api.whatsapp.com/send?phone=%s&text=%s" % (record.partner_id.mobile, message),
'target': 'new',
}

everything is working but in the share link in two places we have "&" and the link will trime from & and result is like bellow:

Hello Kamranlpr,Your quotation S02317 amounting in 1050.0 is ready for review. Here's the link to view it: https://erp.gyc.com/mail/view?model=sale.order

so ID and token will trime.

i was wondering if anyone can help me to solve the problem.

0
Awatar
Odrzuć
Awatar
Leandro Carignano
Najlepsza odpowiedź
Hello, I'm trying to create that action in Odoo and I can't get it to work. Would you send me the complete code?


0
Awatar
Odrzuć
Kamran Lalehparvar
Autor

Hi this is the full code for sale order
if not record.partner_id.mobile:
raise UserError('No mobile number found for the selected partner.')
else:
# create link
target_url = "https://erp.gyeongcc.com" + record.get_portal_url()
link_tracker = env['link.tracker'].search([('url', '=', target_url)], limit=1)
if not link_tracker:
link_tracker = env['link.tracker'].create({
'title': record.name,
'url': target_url,
})

if record.state == 'sale':
# create message for WhatsApp (specific to sales order)
message_whatsapp = "Hello %s%%0AYour order *%s* amounting in *%s* *%s* is has been confirmed.%%0AThank you for your trust!%%0Alink to view: %s%%0ADo not hesitate to contact us if you have any questions." % (record.partner_id.name, record.name, record.amount_total, record.currency_id.name, link_tracker.short_url)

# create message for chatter (specific to sales order)
message_chatter = "Hello %s<br> Your order <b>%s</b> amounting in <b>%s %s</b> has been confirmed.<br>Thank you for your trust!<br>link to view: %s<br>Do not hesitate to contact us if you have any questions." % (record.partner_id.name, record.name, record.amount_total, record.currency_id.name, link_tracker.short_url)
else:
# create message for WhatsApp (specific to quotation)
message_whatsapp = "Hello %s%%0AYour quotation *%s* amounting in *%s* *%s* is ready for review.%%0AHere's the link to view it: %s%%0ADo not hesitate to contact us if you have any questions." % (record.partner_id.name, record.name, record.amount_total, record.currency_id.name, link_tracker.short_url)

# create message for chatter (specific to quotation)
message_chatter = "Hello %s<br> Your quotation <b>%s</b> amounting in <b>%s %s</b> is ready for review.<br> Here's the link to view it: %s<br>Do not hesitate to contact us if you have any questions." % (record.partner_id.name, record.name, record.amount_total, record.currency_id.name, link_tracker.short_url)

# create action for WhatsApp
action = {
'name': "WhatsApp",
'type': 'ir.actions.act_url',
'url': "https://api.whatsapp.com/send?phone=%s&text=%s" % (record.partner_id.mobile, message_whatsapp),
'target': 'new',
}

# create message for chatter
body = "<div style='background-color:#EAF4E8; padding: 10px;'><b>WhatsApp message sent:</b><br/>" + message_chatter + "</div>"
record.message_post(body=body)

Leandro Carignano

Thank you very much, I have a problem with the link created. This link returns me:

http://ariano.com.ar/r/p1Z

Could it be that I'm missing the record.get_portal_url() action somewhere else?

Leandro Carignano

As requested, the URL parameter of my site was wrong.
Goes perfectly!

Thank you so much!

Awatar
Jainesh Shah(Aktiv Software)
Najlepsza odpowiedź

Hello Kamran Lalehparvar,

You can parse the link in URL form with python library "urllib" to solve this issue.
Update your message as below

Please find code in comments. 

Hope it will be helpful to you.

Thanks & Regards,
Email:  odoo@aktivsoftware.com

Skype: kalpeshmaheshwari 

0
Awatar
Odrzuć
Jainesh Shah(Aktiv Software)

Please find code here :-

# Header
import urllib.parse

# create message
url = "https://erp.gyc.com/mail/view?" + urllib.parse.quote("model=sale.order&res_id=%s&access_token=%s" %(record.id, record.access_token))

message = "Hello %s,
Your quotation %s amounting in %s %s is ready for review.
Here's the link to view it: %s
Regards," % (record.partner_id.name, record.name, record.amount_total, record.currency_id.name, url)

Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
Why write permission is checked when executing a server action?
server_actions odoo16features
Awatar
Awatar
Awatar
2
wrz 25
1723
How to create Server Action based on view type? Rozwiązane
server_actions serveraction odoo16features
Awatar
Awatar
1
lis 23
3727
DeprecationWarning: The longpolling-port is a deprecated alias to the gevent-port option, please use the latter Rozwiązane
odoo16features
Awatar
Awatar
Awatar
Awatar
Awatar
5
wrz 25
24608
How to Add wizard under print button inside the form view.
odoo16features
Awatar
Awatar
Awatar
Awatar
3
sie 25
3756
How to add @api.onchange in _get_view() method odoo 16
odoo16features
Awatar
Awatar
1
maj 25
3660
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now