In Odoo 15, How can I trigger a webhook data to an external system whenever records are created, updated, or deleted by Odoo's system.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Бухгалтерия
- Склад
- PoS
- Project
- MRP
Этот вопрос был отмечен
1
Ответить
2602
Представления
Hello,
In that case, you need to develop a custom method for the webhook and you need to call that method based on CURD operations.
Eg. code
@api.model
def create(self, vals):
record = super(MyModel, self).create(vals)
self.send_webhook_notification('create', record)
return record
def write(self, vals):
res = super(MyModel, self).write(vals)
self.send_webhook_notification('update', self)
return res
def unlink(self):
res = super(MyModel, self).unlink()
self.send_webhook_notification('delete', self)
return res
def send_webhook_notification(self, action, record):
# Construct webhook payload
payload = {
'action': action,
'record_id': record.id,
'record_name': record.name,
# Add more fields as needed
}
# Send webhook request
webhook_url = 'https://your-webhook'
requests.post(webhook_url, json=payload)
Thanks
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
РегистрацияRelated Posts | Ответы | Просмотры | Активность | |
---|---|---|---|---|
|
2
июл. 24
|
1224 | ||
|
2
июл. 24
|
2756 | ||
|
2
мар. 24
|
3427 | ||
|
1
дек. 22
|
3207 | ||
|
0
авг. 21
|
3048 |