Commit Graph
31 Commits
Author SHA1 Message Date
Yannick Payot d17d229b13 Change CI to GitHub actions
Use copier template from oca/oca-addons-repo-template

Apply linting
2023-05-24 18:22:55 +02:00
Vincent RenavilleandGitHub fc452c6a2a feat: remove after method (#393)
* fix: azure reading in stream monkey patch documents
2022-11-11 15:17:03 +01:00
Vincent RenavilleandGitHub dddd130e79 fix: dependencies and deprecated code (#390) 2022-11-04 14:34:29 +01:00
Vincent RenavilleandGitHub 14cab08024 fix: modifition setup (#386) 2022-09-26 11:31:17 +02:00
vrenaville afc02b779f feat: v16.0 : all modules uninstallable 2022-09-26 10:12:15 +02:00
Stephane ManginandMaksym Yankin 361891fedb Object storage inactivation: changes INACTIVE concept for DISABLE 2022-05-18 16:24:50 +03:00
Stephane ManginandMaksym Yankin f06ac95508 Object Storage - inactive mode 2022-05-18 16:24:32 +03:00
Denis Leemann a8b4b251ef Update manifest files to be consistent inbetween them
The main goal is to be able to easily do grep and sed when we
do mass update on them
2021-10-18 13:08:30 +02:00
Denis Leemann e03fadfd21 15.0 Modules migration 2021-10-18 13:08:30 +02:00
Don Kendall 7ec3a1c94d remove base64 from base_attachment 2020-11-04 20:09:15 -05:00
Patrick Tombez 4d665d96c1 [MIG] base_attachment_object_storage: Migration to 14.0 2020-11-03 15:30:48 +01:00
Denis Leemann 287332576a Set module for 14.0 uninstallable 2020-10-06 10:54:24 +02:00
Guewen Baconnier e3e3899143 Rework and fix storage forced in database
The initial issue that triggered this rework is that the forced storage in
database was working only on writes, and was never applied on attachment
creations.

This feature is used to store small files that need to be read in a fast way in
database rather than in the object storage. Reading a file from the object
storage can take 150-200ms, which is fine for downloading a PDF file or a single
image, but not if you need 40 thumbnails.

Down the path to make a correction, I found that:

* the logic to force storage was called in `_inverse_datas`, which is not called
  during a create
* odoo implemented a new method `_get_datas_related_values`, which is a model
  method that receive only the data and the mimetype, and return the attachment
  values and write the file to the correct place

The `_get_datas_related_values` is where we want to plug this special storage,
as it is called for create and write, and already handle the values and
conditional write. But using this method, we have less information than before
about the attachment, so let's review the different criterias we had before:

* res_model: we were using it to always store attachments related to
  'ir.ui.view' in db, because assets are related to this model. However, we
  don't really need to check this: we should store any javascript and css
  documents in database.
* exclude res_model: we could have an exclusion list, to tell that for instance,
  for mail.message, we should never store any image in db. We don't have this
  information anymore, but I think it was never used and added "in case of".
  Because the default configuration is "mail.mail" and "mail.message" and I
  couldn't find any attachment with such res_model in any of our biggest
  databases. So this is removed.
* mimetype and data (size) are the last criteria and we still have them

The new system is only based on mimetype and data size and I think it's actually
more versatile. Previously, we could set a global size and include mimetypes,
but we couldn't say "I want to store all images below 50KB and all files of type
X below 10KB". Now, we have a single system parameter with a dict configuration
(`ir_attachment.storage.force.database`) defaulting to:

    {"image/": 51200, "application/javascript": 0, "text/css": 0}

Assets have a limit of zero, which means they will all be stored in the database
whatever their size is.

Overall, this is a great simplification of the module too, as the method
`_get_datas_related_values` integrates it better in the base calls of IrAttachment.

Note for upgrade:

I doubt we customized the previous system parameters which are now obsolete, but
if yes, the configuration may need to be moved to `ir_attachment.storage.force.database`.
For the record, the params were:

* mimetypes.list.storedb (default: image)
* file.maxsize.storedb (default: 51200)
* excluded.models.storedb (mail.message,mail.mail), no equivalent now

The method IrAttachment.force_storage_to_db_for_special_fields() should be called
through a migration script on existing databases to move the attachments back into
the database.
2020-05-28 07:26:42 +02:00
Guewen Baconnierandvrenaville 3d25e59f0f Add method to force storage of special attachments to DB
Some attachments (e.g. image_small, image_medium) are stored in DB
instead of the object storage for faster access.

In some situations, we may have pushed all these files on the Object
Storage (migration from a filesystem to object storage) and want to
bring back these attachments from the object storage to the database.

This method is not called anywhere but can be called by RPC or scripts.
2019-12-20 13:23:48 +01:00
vrenaville 29e6271a70 [IMP] route file to db base on size and mimetype 2019-12-05 09:34:23 +01:00
Akim Juillerat a7e364f93b [MIG] base_attachment_object_storage: Migration to 13.0 2019-10-08 17:10:36 +02:00
Tonow-c2c cbff157fdd BSRD-286: Set the addons to uninstallable 2019-10-07 12:16:06 +02:00
Akim Juillerat 626c157964 [IMP]: Allow to use context Key as storage key 2019-03-11 15:39:53 +01:00
Akim Juillerat 498aae2f53 [IMP]: Allow to pass storage as a context key 2019-03-11 15:39:53 +01:00
jcoux 5c43e3547e fixup! Migration to 12.0 2018-11-23 09:31:46 +01:00
jcoux 7eac1013eb Migration to 12.0 2018-10-24 12:44:45 +02:00
jcoux 73293a1390 Set all modules to uninstallable 2018-10-24 11:53:27 +02:00
Guewen Baconnier 96f4e75311 base_attachment_object_storage: bump 1.1.0 2018-06-13 17:25:21 +02:00
Guewen Baconnier 371e5439e6 Document a weird domain which is there for a reason
The reason being:
https://github.com/odoo/odoo/blob/9032617120138848c63b3cfa5d1913c5e5ad76db/odoo/addons/base/ir/ir_attachment.py#L344-L347

I nearly deleted this domain but it was too weird to be there for no
reason. A comment explaining the issue was really missing.
2018-06-13 16:05:34 +02:00
Guewen Baconnier 6ab3038a90 Fix attachments stored in FS instead of object storage
Assume the following situation:

* We have installed addons base, sale and attachment_s3 (hence
base_attachment_object_storage as dependency)
* All attachments are in S3 already
* We run an upgrade of the 'base' addon, 'sale' is upgraded before
attachment_s3 in the order of loading.
* Sale updates the icon of the Sale menu
* As attachment_s3 is not loaded yet, the attachment is created in the
filestore

Now if we don't persist the filestore or use different servers, we'll
lose the images of the menus (or any attachment loaded by the
install/upgrade of an addon).

The implemented solution is to move the attachments from the filestore
to the object storage at the loading of the module. However, this
operation can take time and it shouldn't be run by 2 processes at the
same time, so we want to detect if the module is loaded during a normal odoo
startup or when some addons have been upgraded. There is nothing anymore
at this point which allow us to know that modules just have been
upgraded except... in the caller frame (load_modules). We have to rely
on the inpect module and get the caller frame, which is not recommended,
but seems the only way, besides, it's not called often and if
_register_hook was called from another place, it would have no effect
(unless the other place has a variable 'update_module' too).
2018-06-13 16:05:26 +02:00
Guewen Baconnier fb3d3134d6 Ensure that migration of files is commited before deleting files
When moving attachments from the filestore to an object storage,  the
filesystem files will be deleted only after the commit, so if the
transaction is rollbacked, we still have the local files for another
try.
2018-06-13 16:04:55 +02:00
Guewen Baconnier 08329c91d2 Replace value.decode('base64') by base64.b64decode (py3) 2017-11-15 15:54:59 +01:00
Guewen Baconnier b084ce278a Set addons installable 2017-11-15 14:56:45 +01:00
Guewen Baconnier 96c9a38150 Set addons uninstallable 2017-11-15 14:31:23 +01:00
Guewen Baconnier cbef735c76 Abstract object storage in attachment_s3
Using the base_attachment_object_storage module, the same way
attachment_swift is done. Fixed a few issues along the way in
attachment_swift.
2017-09-20 15:42:25 +02:00
Thierry DucrestandGuewen Baconnier fea698057a Create base_attachment_object_storage to extract common code to store implementations 2017-09-01 11:14:21 +02:00