OCA / storage

GNU Affero General Public License v3.0
70 stars 159 forks source link

[16.0][FIX] fs_attachment: Fix attachment store after upgrade #304

Open lmignon opened 10 months ago

lmignon commented 10 months ago

Fix attachments stored in Odoo after an addon upgrade.

Prerequisites:

Context:

Problem:

Some attachments could be created during the upgrade process before the load of the fs_attachment module or the configuration of the filesystem storage backends. This is especially true for the attachments created by addons to store the app icons or even attachments from XML data files. As a result, you end up with attachments that could not be found by some Odoo instances if, for example, you have multiple Odoo instances running on different servers since these attachments are stored in the odoo filestore of the server that created them.

Solution:

A solution to this problem is to hook the end of the upgrade process through the implementation of the _register_hook method on our ir.attachment model. Since this method is called after the completion of the upgrade process and the full initialization of the odoo registry, we can safely expect that all the information we need to know where to store the attachments are available. From there, we can simply search for all the attachments that are not linked to any specific storage and store them in the appropriate storage.

lmignon commented 10 months ago

cc @sbidoul @adrienpeiffer

CasVissers-360ERP commented 6 months ago

@lmignon @sbidoul are you aware that the base vacuuming of Odoo will never run, also for the ignored files?

https://github.com/odoo/odoo/blob/e721ed146d6173cc04efe6103aa6e682fb62917f/odoo/addons/base/models/ir_attachment.py#L165

CasVissers-360ERP commented 6 months ago

In addition I think there is an issue with force_storage #310