Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profitorganisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

Whatsapp Api and share link

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
server_actionsodoo16features
2 Antwoorden
6021 Weergaven
Avatar
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
Avatar
Annuleer
Avatar
Leandro Carignano
Beste antwoord
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
Avatar
Annuleer
Kamran Lalehparvar
Auteur

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!

Avatar
Jainesh Shah(Aktiv Software)
Beste antwoord

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
Avatar
Annuleer
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)

Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
Why write permission is checked when executing a server action?
server_actions odoo16features
Avatar
Avatar
Avatar
2
sep. 25
1720
How to create Server Action based on view type? Opgelost
server_actions serveraction odoo16features
Avatar
Avatar
1
nov. 23
3722
DeprecationWarning: The longpolling-port is a deprecated alias to the gevent-port option, please use the latter Opgelost
odoo16features
Avatar
Avatar
Avatar
Avatar
Avatar
5
sep. 25
24594
How to Add wizard under print button inside the form view.
odoo16features
Avatar
Avatar
Avatar
Avatar
3
aug. 25
3755
How to add @api.onchange in _get_view() method odoo 16
odoo16features
Avatar
Avatar
1
mei 25
3656
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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