-
-
Notifications
You must be signed in to change notification settings - Fork 535
Open
Labels
Description
Summary:
When calling with_delay() multiple times within the same transaction (i.e., before env.cr.commit()), the queue_job system enqueues and executes each job multiple times based on its position in the list. This results in unintended duplicate executions.
Steps to Reproduce:
record.with_delay().write({}) # Expected: 1 execution, Actual: runs once
record.with_delay().write({}) # Expected: 1 execution, Actual: runs twice
record.with_delay().write({}) # Expected: 1 execution, Actual: runs three times
env.cr.commit()
Expected Behavior:
Each call to with_delay() should schedule exactly one job to be run after commit.
Actual Behavior
Each job appears to be executed multiple times, depending on how many prior with_delay() calls were made in the same transaction. You can observe this by the current retry count on the job record — even though no exceptions are raised that would normally trigger retries.
Environment:
Odoo Version: Odoo 17.0+e-20240201 (Enterprise Edition)