Skip to Content
Menu
This question has been flagged
2 Replies
117 Views

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

Avatar
Discard
Best Answer

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

Avatar
Discard
Best Answer

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.

Avatar
Discard

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

Related Posts Replies Views Activity
2
Aug 25
1264
0
Feb 25
1434
1
Jan 25
1967
2
Dec 24
1649
1
Nov 24
155