Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

Send SMS from Python in Automated Action

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
pythonAutomatedActionsSMS
2 Risposte
3797 Visualizzazioni
Avatar
Charles Kirby

I'm trying to send a SMS message via python in an automated action. I couldn't find any specific documentation regarding this but I did come across a couple of similar posts. 


I've tried this:
sms_pool = env['sms.template']
sms_template = sms_pool.search(['&', ('model_id', '=', 'sale.subscription'), ('id', '=', 9)])
sms_template.send_sms(subscription.id)


Which is similar to how I send email templates. But I receive "send_sms" is not a function. If this technique works, what function should I use (instead of 'send_sms') to send the message?


I've also tried:
#sms_obj = env['sms.composer'].create({
# 'numbers': sms_phone,
# 'body': sms_body
#})
#sms_obj.action_send_sms()

but I receive an invalid recipient message. I've tried to format the phone number in various ways without success. 


Can someone please point me in the right direction regarding what I'm missing to make this happen.


0
Avatar
Abbandona
Avatar
Charles Kirby
Autore Risposta migliore

Thank you for the response. Unfortunately, I'm still having trouble with this technique as well. I am trying to do this from within an Automated Action (not the back-end Python libraries, which is where it looks like your example is meant to be used).


From what I can tell, I have the SMS module installed and working properly. I have "sms.api" available in my "Models" list. I have sufficient credits purchased for sending a SMS message. I can successfully send a SMS message to a Contact when I do so manually or as part of SMS Marketing campaigns. 


Whenever I call sms_api.send_sms, I receive the following error:

ValueError: : "'sms.api' object has no attribute 'send_sms'" while evaluating


0
Avatar
Abbandona
Avatar
shubham shiroya
Risposta migliore

Here's an example of how you can send an SMS message using this module:

from odoo import api, models

class YourModel(models.Model):
_name = 'your.model'

def send_sms_message(self):
# Get the SMS API object
sms_api = self.env['sms.api']

# Define the recipient phone number and message body
recipient_number = '123456789' # Replace with the actual recipient phone number
message_body = 'Hello, this is a test SMS message.'

# Send the SMS message
sms_api.send_sms(recipient_number, message_body)

In this example, you can create a method send_sms_message in your model and call it to send an SMS message. Replace '123456789' with the actual recipient's phone number, and 'Hello, this is a test SMS message.' with the desired message body.

Make sure you have the sms module installed and configured correctly in your Odoo instance. Also, ensure that you have configured the SMS gateway settings in Odoo, including the SMS API credentials.

If you're still facing issues with sending SMS messages, double-check the recipient's phone number format. It should follow the format expected by your SMS gateway provider (e.g., including the country code).

0
Avatar
Abbandona
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
Automated action doesn't work in Odoo 16 but Odoo 14
python AutomatedActions
Avatar
Avatar
1
nov 23
3151
Need Python code to run the Compute Price from BOM server action Risolto
python AutomatedActions
Avatar
Avatar
2
dic 23
6990
Please help me with odoo 14 community automated action Risolto
python AutomatedActions
Avatar
Avatar
1
nov 22
3501
Automated Action: Enrich Event Registration with Partner ID
python AutomatedActions
Avatar
Avatar
1
ago 22
3547
Automated action - Correct syntax for getting the product variant name instead of the product(template) name Risolto
python AutomatedActions
Avatar
Avatar
Avatar
2
gen 22
7002
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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