Hi there
Is there a way via XML RPC webservice, to send notification e-mails to the followers via XML RPC?
(in other words when the record in mail.message with data is created, send mail with contents to the followers)
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi there
Is there a way via XML RPC webservice, to send notification e-mails to the followers via XML RPC?
(in other words when the record in mail.message with data is created, send mail with contents to the followers)
Hi there. Many thanks for this quick and complete answer.
I'm trying to test it, but when i try this:
return self.models.execute_kw(self.dbName, self.uid, self.dbPassword, 'mail.thread', 'message_post', [[recordId], message, {}])
I get the message:
raise ValueError("Expected singleton: %s" % self)\nValueError: Expected singleton: mail.thread([291159], \'test bericht\', {})\n'>
Can you tell me what i'm doing wrong?
Hi,
Yes, you can send notification emails to the followers of a record in Odoo via XML-RPC web services. Odoo provides various methods in its XML-RPC API to achieve this.
To send notification emails to the followers of a record, you can use the message_post method from the mail.thread model. Here's a high-level overview of how to do it:
import xmlrpc.client
url = 'http://your-odoo-instance.com'
db = 'your-database-name'
username = 'your-username'
password = 'your-password'
common = xmlrpc.client.ServerProxy(f'{url}/xmlrpc/2/common')
uid = common.authenticate(db, username, password, {})
models = xmlrpc.client.ServerProxy(f'{url}/xmlrpc/2/object')
record_id = 123 # Replace with the ID of the record you want to notify followers about
message = "This is your notification message."
# Call message_post to send the notification email
models.execute_kw(db, uid, password, 'mail.thread', 'message_post', [[record_id], message, {}])
In this example, you need to replace the placeholders with your actual Odoo instance details and the ID of the record you want to notify. You can also customize the message variable to include the content of the email.
Make sure that the user specified in the authentication process has the necessary permissions to send messages and notify followers. Additionally, you may need to handle error handling and exceptions in your code to ensure robust functionality.
By using the message_post method, you can send notification emails to the followers of a record via Odoo's XML-RPC web service.
Hope it helps
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up