Skip to content

Commit

Permalink
[FIX] base: webhook actions sample payload
Browse files Browse the repository at this point in the history
Before this commit, the sample payload displayed next to server actions
of type 'webhook' didn't respect the format of the actual payload sent
by `_run_action_webhook`.

This commit fixes that by adjusting the
`_compute_webhook_sample_payload` method so it includes the exact same
keys and values that will be sent by the server action when ran.

closes odoo#199018

Signed-off-by: Bruno Boi (boi) <[email protected]>
  • Loading branch information
odoostan committed Feb 24, 2025
1 parent 09b1678 commit a3a2e1f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions odoo/addons/base/models/ir_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,15 +749,15 @@ def _compute_webhook_sample_payload(self):
action.webhook_sample_payload = False
continue
payload = {
'id': 1,
'_id': 1,
'_model': self.model_id.model,
'_name': action.name,
'_action': f'{action.name}(#{action.id})',
}
if self.model_id:
sample_record = self.env[self.model_id.model].with_context(active_test=False).search([], limit=1)
for field in action.webhook_field_ids:
if sample_record:
payload['id'] = sample_record.id
payload['_id'] = sample_record.id
payload.update(sample_record.read(self.webhook_field_ids.mapped('name'), load=None)[0])
else:
payload[field.name] = WEBHOOK_SAMPLE_VALUES[field.ttype] if field.ttype in WEBHOOK_SAMPLE_VALUES else WEBHOOK_SAMPLE_VALUES[None]
Expand Down

0 comments on commit a3a2e1f

Please sign in to comment.