diff --git a/addons/base_automation/models/base_automation.py b/addons/base_automation/models/base_automation.py index ebe5cb4bc76..dcb2031294f 100644 --- a/addons/base_automation/models/base_automation.py +++ b/addons/base_automation/models/base_automation.py @@ -86,7 +86,8 @@ class BaseAutomation(models.Model): ) url = fields.Char(compute='_compute_url') webhook_uuid = fields.Char(string="Webhook UUID", readonly=True, copy=False, default=lambda self: str(uuid4())) - record_getter = fields.Char(help="This code will be run to find on which record the automation rule should be run.\nExample: model.browse(payload.get('recordId')))") + record_getter = fields.Char(default="env[payload.get('_model')].browse(payload.get('id'))", + help="This code will be run to find on which record the automation rule should be run.") log_webhook_calls = fields.Boolean(string="Log Calls", default=False) active = fields.Boolean(default=True, help="When unchecked, the rule is hidden and will not be executed.") diff --git a/addons/base_automation/views/base_automation_views.xml b/addons/base_automation/views/base_automation_views.xml index f2b909822ab..c3d71deb809 100644 --- a/addons/base_automation/views/base_automation_views.xml +++ b/addons/base_automation/views/base_automation_views.xml @@ -105,8 +105,9 @@
- Available variables: -
    +
    The default target record getter will work out-of-the-box for any webhook coming from another Odoo instance.
    + Available variables: +
    • env: environment on which the action is triggered
    • model: model of the record on which the action is triggered; is a void recordset
    • time, datetime, dateutil, timezone: useful Python libraries
    • @@ -156,6 +157,7 @@ 'remove_followers': 'fa-user-times', 'next_activity': 'fa-clock-o', 'sms': 'fa-comments-o', + 'webhook': 'fa-paper-plane', }[record.state.raw_value]" />