Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
134 Widoki

I kept getting this error "The domain involves non-literals. Their evaluation might fail."

​I want to make an automation if a lead has no not been updated 4 days after it has been creaed, it will trigger a To-Do activity. This is how i set it up but i kept on getting the error. Please help me fix this issue.

 Model: Lead

Trigger: On Create and Edit

Apply On: Stage is equal XXX, Last Updated on nect 4 days

Activity: To-Do

Awatar
Odrzuć
Najlepsza odpowiedź

Hi,


The error happens because date-based filters like "Next 4 days" involve dynamic expressions, which automated actions (server actions/studio rules) in Odoo do not always support reliably, especially when combined with "On Create and Edit" triggers.


Instead of triggering "On Create/Edit", the correct and stable way is to use a Scheduled Action (Cron job) that runs daily and checks if any leads are older than 4 days and have not been updated.


Try the following steps.

1- Go to Settings > Technical > Automation > Scheduled Actions

Create a new one:

          Model: crm.lead

          Name: "Check inactive leads > 4 days"

        Active: True

        Interval Number: 1

         Interval Unit: Days

         Next Execution Date: Today

         Action To Do: Execute Python Code

2. Use this Python Code:

from datetime import datetime, timedelta


four_days_ago = datetime.now() - timedelta(days=4)

leads = model.search([

    ('stage_id.name', '=', 'XXX'),  # Replace XXX with your stage name

    ('write_date', '<', four_days_ago),

])


for lead in leads:

    lead.activity_schedule(

        'mail.mail_activity_data_todo',

        summary="Follow up with lead",

        note="This lead hasn't been updated in over 4 days.",

        user_id=lead.user_id.id or False,

    )


- If you're using Odoo Studio, try using a workaround with an invisible computed field:

       * Add a new boolean field like lead_stale.

       * Compute it via a scheduled action or automated server action (using Python).

       * Use this field to trigger activities, avoiding literal date comparison in domains.


Hope it helps

Awatar
Odrzuć
Najlepsza odpowiedź

To fix this, you need to change your approach. The most common and correct way to implement the "X days after creation, if not updated" automation is to use Scheduled Actions or Time-Based Workflow Rules, instead of triggering "On creation and edit" with complex date filters.

Awatar
Odrzuć

If you need more information please join: https://googledoodlebaseball.io/

Powiązane posty Odpowiedzi Widoki Czynność
2
sie 25
1287
0
lut 25
1442
1
sty 25
1981
2
gru 24
1663
1
lis 24
155