Skip to content

Conversation

@sbejaoui
Copy link
Contributor

wrap move creation in a savepoint to avoid leaving the cursor in an error state when an SQL constraint is raised, without this, the explicit commit after the exception fails

fixes: #24

@sbejaoui sbejaoui requested a review from sbidoul December 31, 2025 11:14
@sbejaoui
Copy link
Contributor Author

cc/ @jbaudoux

wrap move creation in a savepoint to avoid leaving the cursor in an error
state when an SQL constraint is raised, without this, the explicit commit
after the exception fails

fixes: #24
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.89%. Comparing base (57e6867) to head (bbd089d).

Additional details and impacted files
@@            Coverage Diff             @@
##             16.0      #25      +/-   ##
==========================================
+ Coverage   65.49%   65.89%   +0.39%     
==========================================
  Files          43       43              
  Lines        1339     1340       +1     
  Branches      188      188              
==========================================
+ Hits          877      883       +6     
+ Misses        405      402       -3     
+ Partials       57       55       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sbidoul sbidoul merged commit be30ed5 into 16.0 Jan 2, 2026
6 checks passed
@sbidoul sbidoul deleted the 16.0-issue_24-sbj branch January 2, 2026 13:45
@sbidoul
Copy link
Member

sbidoul commented Jan 2, 2026

Thanks! 👍

proxy_acks.append(uuid)

if not tools.config['test_enable']:
self.env.cr.commit() # pylint: disable=invalid-commit
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbidoul I remember you once mentioned that using explicit commits isn’t compatible with running crons through queue_job

We have a case that seems related: the “retrieve new document” cron is configured to run as a queue job. We noticed that some invoices gets created multiple times

When we looked at the data/timestamps, most duplicates were created before the job actually started, and only one invoice was created after it. However, the job itself was executed twice, so our hypothesis is:

  • first run: Odoo downloaded the document, created the invoice, then commited
  • then the run failed/crashed before before marked the document as already imported in server side
  • second run: it downloaded the same document again

Do you think switching this cron back to “run in odoo” (not queue job) would solve it?
If not, do you have thoughts on this?

cc/ @phschmidt , @jbaudoux

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember you once mentioned that using explicit commits isn’t compatible with running crons through queue_job

Yes. When you commit in a queue_job, it releases the queue_job_lock and the dead job requeuer starts it again a few seconds later.

I'm planning to do a queue_job PR to raise an error on commit in queue jobs, but have not found the time to do it yet.

Do you think switching this cron back to “run in odoo” (not queue job) would solve it?

Very possibly yes. That said, the other rule of queue jobs (and crons) is that they should be idempotents. I dont know if this particular cron is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR to prevent commit in queue jobs: OCA/queue#880

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Peppol Get Document failure not properly catched

4 participants