Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
132 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Nejlepší odpověď

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
Zrušit

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

Related Posts Odpovědi Zobrazení Aktivita
2
srp 25
1281
0
úno 25
1441
1
led 25
1980
2
pro 24
1661
1
lis 24
155