Commit Graph
51 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
vrenaville afc02b779f feat: v16.0 : all modules uninstallable 2022-09-26 10:12:15 +02: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
Miku LaitinenandYannick Vaucher 10e8bf6931 [FIX] Bucket name formatting 2021-05-31 09:46:51 +02:00
Yannick Vaucher 83e203c1aa attachment_s3: multi-tenancy use db name in bucket
Adds the possibility to insert `{db}` placeholder in the bucket name
that will be replaced by the database name to form a unique bucket
name per database.
2021-05-18 17:09:38 +02:00
Patrick Tombez 1f0a6974fa [FIX] attachment modules: remove base64 encoding when reading files from storage 2020-11-04 10:41:26 +01:00
Patrick Tombez 049205e560 [MIG] attachment_s3: 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
Stéphane Mangin 2794dc1d96 [13.0] attachement_s3: odoo.modules.registry class name and API changed 2020-08-24 14:15:42 +02:00
Stéphane ManginandGitHub 096c870440 Revert "[13.0] attachement_s3: odoo.modules.registry class name changed" 2020-08-24 13:45:08 +02:00
Stéphane Mangin 1069c8f932 [FIX] attachement_s3: odoo.modules.registry class name changed 2020-08-24 12:11:33 +02:00
Akim JuilleratandGuewen Baconnier 11c90c5a17 [FIX] attachment_s3: Close fileobjects after usage 2020-06-22 07:46:16 +02:00
Akim JuilleratandGuewen Baconnier c89bfc83e0 [IMP] attachment_s3: Consider bin_size context key
When bin_size context key is set, read operations on attachments
are supposed to return the size of the attachment and not its content
2020-06-22 07:46:05 +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
Tonow-c2c 37a3852c80 BSRD-286: MIG V13 attachement_s3 2019-10-08 17:13:34 +02:00
Tonow-c2c cbff157fdd BSRD-286: Set the addons to uninstallable 2019-10-07 12:16:06 +02:00
Yannick Vaucher 8ccddefd06 Fix use of aws where hostname is not required
This fixes an error with endpoint computed as https://None while
we want to let boto compute the AWS endpoint
2019-04-17 14:51:46 +02:00
Akim Juillerat 58d526d8cf Add https scheme if not present in AWS_HOST env var
With boto (odoo < 12.0) we use an hostname as AWS_HOST.
However with boto3, the connection must be initialized using an
URL containing a scheme (e.g https://)
This commit ensures we can use a simple hostname for odoo >= v12.0
without the need of specifying the scheme in the env var.
2019-04-03 14:48:53 +02:00
Akim Juillerat 498aae2f53 [IMP]: Allow to pass storage as a context key 2019-03-11 15:39:53 +01:00
Akim Juillerat c61cf6c4e5 attachment_s3: Migrate to boto3 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 6cc18007dd Remove web_kanban, does no longer exist in 11.0 2018-01-11 10:41:26 +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
Yannick Vaucher a3c0322982 Add AWS_REGION to connect to bucket with specific region 2017-11-13 16:29:01 +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
Guewen Baconnier f1e84b5562 Make error message more precise for S3 access
The previous error message let think that you should set AWS_BUCKETNAME,
although you should set it only if you are trying to write in this
repository.
2017-08-28 14:37:45 +02:00
Guewen Baconnier 795692ad78 Store files that need fast access in the database
An Object Storage read is slower than a disk of database access.
It might take ~200 to 300ms to retrieve a file content.

This is not an issue for attachments such as the pdf files or any
attachment that we want to read on demand. But that's too slow for
files needed to render a web page.

We'll store in the database:

* Assets (js, css, ...). As a side effect, the databases will be more
  portable, as assets are rebuilt frequently, storing them in the Object
  Storage led the integration server to try to read assets deleted since
  long ago
* Attachments linked to Binary fields named 'image_small',
  'image_medium', 'web_icon_data'. Those fields are often used on kanban
  views that display a lot a images and retrieving them all was then
  very slow (Odoo does not do async requests).

The migration to S3 is no longer called during initialization of the
registry: it would be too slow as we would have to define if the
attachments must be kept in database or sent to S3 on each new start. It
means we have to call `env['ir.attachment'].force_storage()` to run the
migration.
2017-01-16 14:04:24 +01:00
Guewen Baconnier 8e4b461c75 Migrate addons to 10.0 2016-12-21 21:29:09 +01:00
Guewen Baconnier 997f92aaab Rename builtin id variable 2016-12-13 12:21:37 +01:00
Guewen Baconnier d138a1fd3d Be more defensive against concurrent workers
When migrating attachments to S3, several workers may try to migrate
the same attachments. Do not fail when both update the same attachment.
2016-12-13 12:01:50 +01:00
Guewen Baconnier 5f61ed8985 registry is useless in the second branch 2016-12-13 09:06:50 +01:00
Guewen Baconnier 53d7cdf3e7 Fix attachment_s3: do not open a new cursor
Because it provokes serialization errors during the installation or
update of addons. Do not commit as we might commit unwanted things...
Later, we might want to add a specific, more elaborate, migration
process.
2016-12-13 08:58:08 +01:00
Guewen BaconnierandGitHub 8b15070c7f Merge pull request #4 from guewen/add-load-readme
Document --load option for some addons
2016-11-14 08:29:51 +01:00
Guewen Baconnier 607268bd4f Delete S3 file only when bucket is the current one 2016-11-14 08:29:13 +01:00
Guewen Baconnier 779aa03c57 Explicit attachment_s3 must be started in --load 2016-11-10 16:14:19 +01:00
Guewen Baconnier 110ec2399d Add logging when deleting file on the object storage 2016-11-07 10:11:23 +01:00
Guewen Baconnier 7f262799cf Do not care if an attachment could not be deleted 2016-11-07 09:50:26 +01:00
Guewen Baconnier f643c19fba Do not fail when an attachment cannot be read
It would be blocking and a missing attachment might be a minor issue.
Only warn when such a file is missing.
2016-11-04 13:38:31 +01:00
Guewen Baconnier 3c8b74369b Make pylint happy 2016-11-03 16:58:36 +01:00
Guewen Baconnier b5f00c26dc Fix pep8 2016-11-02 10:29:02 +01:00
Guewen Baconnier 46231b3365 Fix pep8 2016-11-02 09:55:36 +01:00
Guewen Baconnier 1d4f76de2b Migrate attachments s3 to new pattern
So remove the compatibility code altogether
2016-11-01 08:55:00 +01:00
Guewen Baconnier 963b65e99d Storage should be 's3' 2016-10-31 17:23:20 +01:00
Guewen Baconnier 73aaff62fc Rework attachment_s3:
* store the S3 uri in the 'store_fname' (s3://bucket/key)
* the read-only mode is now built-in, as we store the bucket name, if a
  instance is started with a different bucket or another filestore
  method, it will continue to read the previous attachments on their
  stored bucket, but new attachments will be stored on the new one
* remove config in ir.config_parameter, it makes all the stuff more
  complex and we don't use them (config file would be more interesting)
* automatically migrate the attachments on loading of the server, so
  if an ir.attachment has been created during the module
  upgrade/initialization before attachment_s3 is loaded, it will be sent
  to S3 as soon as it's loaded
2016-10-31 13:57:20 +01:00
Guewen Baconnier 9ca3f87614 Remove the bin_size return
When we return a bin_size (such as 28672), the web client does not
accept it as as bin size and try to use it as value for the b64 src of
the image.  Though, returning the image as b64 in all cases does seem to
be supported.
2016-10-24 17:12:27 +02:00
Guewen Baconnier ec59d275e2 Add read-only mode that fallbacks on the database 2016-10-24 17:12:27 +02:00