Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

Send SMS from Python in Automated Action

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
pythonAutomatedActionsSMS
2 Besvarelser
3796 Visninger
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
Kassér
Avatar
Charles Kirby
Forfatter Bedste svar

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
Kassér
Avatar
shubham shiroya
Bedste svar

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
Kassér
Enjoying the discussion? Don't just read, join in!

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

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
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 Løst
python AutomatedActions
Avatar
Avatar
2
dec. 23
6989
Please help me with odoo 14 community automated action Løst
python AutomatedActions
Avatar
Avatar
1
nov. 22
3501
Automated Action: Enrich Event Registration with Partner ID
python AutomatedActions
Avatar
Avatar
1
aug. 22
3546
Automated action - Correct syntax for getting the product variant name instead of the product(template) name Løst
python AutomatedActions
Avatar
Avatar
Avatar
2
jan. 22
7001
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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