Wednesday, April 30, 2025
1 change · master
Resolved issues and error corrections
AI agent attachments are now linked directly to their owning agent so access permissions can be checked reliably. This prevents users from encountering attachment access issues, with the trade-off that duplicated attachments may need their AI embeddings recalculated.
Original PR description
Using a `Many2many` for the `attachment_ids` and `url_attachment_ids` fields was problematic. The `ir.attachment` model is meant to be used as a `Many2one` or `One2Many` since it is linked to its parent record using ressource fields (`res_model` and `res_id`). When using a `Many2many` field, the `res_id` loses its meaning since it should be able to include multiple IDs to be accurate. In practice, this caused an access rights issue because the `ir.attachment` model [1] relies on the `res_id` to check which user is allowed to access the attachment. To fix this, the attachment fields of the agent are replaced with `One2many` fields. This implies that the attachments aren't shared anymore and the embedding will need to be recomputed in case of duplicated attachments across multiple agents. [1] See function `check` of `base/models/ir_attachments.py`