Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

Whatsapp Api and share link

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
server_actionsodoo16features
2 Răspunsuri
6020 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
Imagine profil
Leandro Carignano
Cel mai bun răspuns
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
Imagine profil
Abandonează
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!

Imagine profil
Jainesh Shah(Aktiv Software)
Cel mai bun răspuns

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
Imagine profil
Abandonează
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)

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Why write permission is checked when executing a server action?
server_actions odoo16features
Imagine profil
Imagine profil
Imagine profil
2
sept. 25
1718
How to create Server Action based on view type? Rezolvat
server_actions serveraction odoo16features
Imagine profil
Imagine profil
1
nov. 23
3720
DeprecationWarning: The longpolling-port is a deprecated alias to the gevent-port option, please use the latter Rezolvat
odoo16features
Imagine profil
Imagine profil
Imagine profil
Imagine profil
Imagine profil
5
sept. 25
24589
How to Add wizard under print button inside the form view.
odoo16features
Imagine profil
Imagine profil
Imagine profil
Imagine profil
3
aug. 25
3753
How to add @api.onchange in _get_view() method odoo 16
odoo16features
Imagine profil
Imagine profil
1
mai 25
3652
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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