Skip to content

[18.0][FIX] auditlog: Account Invoice Extract Cache Issue (no company set) - #3361

Closed
BT-sschmid wants to merge 1 commit into
OCA:18.0from
brain-tec:18.0.fix_cache_issue
Closed

BT-sschmid wants to merge 1 commit into
OCA:18.0from
brain-tec:18.0.fix_cache_issue

Conversation

@BT-sschmid

@BT-sschmid BT-sschmid commented Sep 4, 2025

Copy link
Copy Markdown

AI Extraction throws an error when auditlog rule with Full log is enabled on account.move.line:

Error while reloading AI data on account.move 13399: We can't leave this document without any company. Please select a company for this document

Module

audit log
https://github.com/OCA/server-tools/blame/22ed5dc4fb76971dbce0bdfd463cff5f1719c2ec/auditlog/models/rule.py#L400

Describe the bug

When using the AI Exctraction for invoices, Odoo tries to map a purchase order.
During this process, the auditlog triggers a cache-invalidation, so that in
https://github.com/brain-tec/odoo/blob/2718aaa7397e38be0fcd64fe6b5ef5c0be66cfe2/addons/purchase/models/account_invoice.py#L85-L87
the reference to the purchase_id is lost.
This happens after setting the invoice_line_ids in
https://github.com/brain-tec/odoo/blob/2718aaa7397e38be0fcd64fe6b5ef5c0be66cfe2/addons/purchase/models/account_invoice.py#L203

To Reproduce

Affected versions: 18

Steps to reproduce the behavior:

  1. upload a bill with a PO reference existing in Odoo
  2. send to AI
  3. Load the results

Expected behavior
No error

This PR removes the cache invalidation. The tests ares still passing, so I guess it is no more needed in v18

@BT-sschmid BT-sschmid changed the title Account Invoice Extract Cache Issue (no company set) [18.0][FIX] auditlog: Account Invoice Extract Cache Issue (no company set) Sep 4, 2025

@StefanRijnhart StefanRijnhart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for your PR and its detailed description. I agree that this line is causing a lot of problems, and that under normal circumstances the green tests validate that it can be safely removed.

The actual issue that it meant to fix involved multi company taxes on products, a situation which could not be reproduced given auditlog's own module dependencies, so we settled for a test on groups and users. This test does not fail after removing the line. However, the issue with products reappears after removing this line.

This week, I was fixing another issue with auditlog and it was caused by the same line. So I'm proposing to replace this line with a more intricate way of cache isolation in #3374. It is accompanied by a dedicated test module that also reproduces the issue with products having taxes in multiple companies. Can I ask you to have a look at that PR and see if we can close this one?

@BT-sschmid

Copy link
Copy Markdown
Author

@StefanRijnhart thanks for the info.
Your PR #3374 is a quite good solution to prevent cache mixups by the audit_log.
I'll close this.

@BT-sschmid BT-sschmid closed this Sep 17, 2025
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.

2 participants