Skip to content

Commit

Permalink
[FIX] base_automation: show filter_domain in debug mode
Browse files Browse the repository at this point in the history
Versions
--------
- 17.0+

Steps
-----
1. Enter debug mode;
2. create an Automation Rule;
3. select Task as model;
4. set trigger to Stage is set to New;
5. set domain to a specific customer;
6. add send email as action;
7. create a task.

Issue
-----
Email is sent after task creation, regardless of the customer.

Cause
-----
The triggers added to 0a744ac automatically compute the
`filter_domain` value, and hide the field in view. With debug mode
enabled, the `filter_pre_domain` field is still visible & editable.

The newly added triggers are applied on both create & update, while
`filter_pre_domain` is only applied on update. This leads to confusion
when clients add a domain which appears to be ignored, as the selected
trigger is immediately hit on creation.

Solution
--------
1. Specify in the help string that `filter_pre_domain` is ignored on
   creation.
2. When entering debug mode, also show the `filter_domain` field,
   allowing users to further modify the domain computed by the selected
   trigger, and helping to distinguish itself from `filter_pre_domain`.

opw-3928082

closes odoo#184464

X-original-commit: 03806a2
Signed-off-by: Levi Siuzdak <[email protected]>
  • Loading branch information
lvsz committed Oct 21, 2024
1 parent cd39af9 commit 41b02e6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion addons/base_automation/i18n/base_automation.pot
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ msgstr ""
#: model:ir.model.fields,help:base_automation.field_base_automation__filter_pre_domain
msgid ""
"If present, this condition must be satisfied before the update of the "
"record."
"record. Not checked on record creation."
msgstr ""

#. module: base_automation
Expand Down
7 changes: 4 additions & 3 deletions addons/base_automation/models/base_automation.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

import datetime
import logging
import traceback
from collections import defaultdict
from uuid import uuid4

from dateutil.relativedelta import relativedelta

from odoo import _, api, exceptions, fields, models
Expand Down Expand Up @@ -65,6 +63,7 @@
'on_time_updated',
]


def get_webhook_request_payload():
if not request:
return None
Expand Down Expand Up @@ -178,7 +177,8 @@ def _check_trigger(self):
string='Before Update Domain',
compute='_compute_filter_pre_domain',
readonly=False, store=True,
help="If present, this condition must be satisfied before the update of the record.")
help="If present, this condition must be satisfied before the update of the record. "
"Not checked on record creation.")
filter_domain = fields.Char(
string='Apply on',
help="If present, this condition must be satisfied before executing the automation rule.",
Expand Down Expand Up @@ -217,6 +217,7 @@ def _check_action_server_model(self):
action_names=', '.join(failing_actions.mapped('name'))
)
)

@api.depends("trigger", "webhook_uuid")
def _compute_url(self):
for automation in self:
Expand Down
14 changes: 12 additions & 2 deletions addons/base_automation/views/base_automation_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,19 @@
options="{'model': 'model_name', 'in_dialog': True}"
invisible="trigger in ['on_webhook', 'on_time', 'on_time_created', 'on_time_updated']"
/>
<label for="filter_domain" invisible="trigger not in ['on_create_or_write', 'on_change', 'on_unlink']"/>
<label for="filter_domain" string="Extra Conditions" invisible="trigger not in ['on_time', 'on_time_created', 'on_time_updated']"/>
<field name="filter_domain" widget="domain" groups="base.group_no_one"
options="{'model': 'model_name', 'in_dialog': True}"
invisible="trigger == 'on_webhook'"
/>
<label for="filter_domain" groups="!base.group_no_one"
invisible="trigger not in ['on_create_or_write', 'on_change', 'on_unlink']"
/>
<label for="filter_domain" groups="!base.group_no_one"
string="Extra Conditions"
invisible="trigger not in ['on_time', 'on_time_created', 'on_time_updated']"
/>
<field name="filter_domain" nolabel="1" widget="domain"
groups="!base.group_no_one"
options="{'model': 'model_name', 'in_dialog': False, 'foldable': True}"
invisible="trigger not in ['on_create_or_write', 'on_change', 'on_unlink', 'on_time', 'on_time_created', 'on_time_updated']"
/>
Expand Down

0 comments on commit 41b02e6

Please sign in to comment.