Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyectos
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

Whatsapp Api and share link

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
server_actionsodoo16features
2 Respuestas
6028 Vistas
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
Descartar
Avatar
Leandro Carignano
Mejor respuesta
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
Descartar
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!

Avatar
Jainesh Shah(Aktiv Software)
Mejor respuesta

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
Descartar
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)

¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
Why write permission is checked when executing a server action?
server_actions odoo16features
Avatar
Avatar
Avatar
2
sept 25
1721
How to create Server Action based on view type? Resuelto
server_actions serveraction odoo16features
Avatar
Avatar
1
nov 23
3723
DeprecationWarning: The longpolling-port is a deprecated alias to the gevent-port option, please use the latter Resuelto
odoo16features
Avatar
Avatar
Avatar
Avatar
Avatar
5
sept 25
24601
How to Add wizard under print button inside the form view.
odoo16features
Avatar
Avatar
Avatar
Avatar
3
ago 25
3755
How to add @api.onchange in _get_view() method odoo 16
odoo16features
Avatar
Avatar
1
may 25
3659
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

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