371 Commits

Author SHA1 Message Date
Guewen Baconnier 298050ba52 Merge pull request #191 from guewen/13.0-log-user-id-uuid
[13.0] Extend json logger with request uuid and user id
2020-06-22 13:36:59 +02:00
Stéphane Bidoul 522937c3b5 Log uid 2020-06-22 07:50:44 +02:00
Stéphane Bidoul 9cf4bf2171 Log request uuid 2020-06-22 07:50:35 +02:00
Akim Juillerat 11c90c5a17 [FIX] attachment_s3: Close fileobjects after usage 2020-06-22 07:46:16 +02:00
Akim Juillerat 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 fd335d89be Upgrade setuptools files 2020-06-22 07:23:56 +02:00
Guewen Baconnier bc7d37d465 Ignore .eggs/ in gitignore 2020-06-22 07:22:45 +02:00
Laurent Mignon (ACSONE) e6f0a82a52 [FIX] logging_json: define dependency override 2020-06-22 07:22:39 +02:00
Guewen Baconnier 787a64178f Merge pull request #183 from avoinsystems/13.0-redis-by-url
[13.0][IMP] session_redis: allow configuring Redis URL instead of host & port.
2020-05-28 20:45:56 +02:00
Guewen Baconnier dcc809d450 Merge pull request #187 from guewen/13.0-fix-force-storage-db
[13.0] Rework and fix storage forced in database
2020-05-28 11:40:14 +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 Baconnier a2e4c8fc65 Merge pull request #178 from guewen/13.0-redis-json-encode-date
Encode/decode date and datetime in redis sessions
2020-05-26 10:43:47 +02:00
Miku Laitinen a383b45f57 [IMP] session_redis: allow configuring Redis URL instead of host & port. 2020-05-14 18:16:55 +03:00
Guewen Baconnier 0769d3b47e Merge pull request #181 from guewen/13.0-fix-server-env
[13.0] Fix build after changes in server_environment
2020-05-11 09:39:53 +02:00
Guewen Baconnier 9bdd4b6b1d Fix build after changes in server_environment
Now the default env is "test", and we don't need the directory
at all.
See https://github.com/OCA/server-env/pull/44
2020-05-11 08:27:16 +02:00
Guewen Baconnier ac89e923d7 Add (de-)serialization of set objects in sessions 2020-05-11 07:35:05 +02:00
Guewen Baconnier 35fb727d6c Encode/decode date and datetime in redis sessions
In several places, odoo sets a datetime object directly in the
session. It works with the default session handler of odoo which
uses pickle.

But datetime and date are not json serializable by default.

Add custom encoder / decoder to handle them (from
https://github.com/OCA/queue/blob/dc12a6a20ecfd15c5b90f9b089c9a64cf9d8bbe4/queue_job/fields.py#L57-L99)

See the discussion raised by @PCatinean on https://github.com/camptocamp/odoo-cloud-platform/pull/176
2020-05-04 16:09:55 +02:00
Akim Juillerat 323158763b Merge pull request #166 from grindtildeath/13.0-fix_auth_to_keystone_v3
[13.0] attachment_swift: Fix authentication to Keystone v3
2020-03-09 13:33:09 +01:00
Akim Juillerat 7bd76d3cd0 Fix authentication to Keystone v3
- Use newer version from python lib.
 - Define project_domain_id + user_domain_id in auth
2020-03-09 13:01:43 +01:00
Akim Juillerat 3470cd4667 Merge pull request #147 from grindtildeath/13.0_dev_attachments
[13.0]Require AWS_BUCKETNAME for prod, integration and labs environments only
2020-03-05 10:13:34 +01:00
Akim Juillerat a372cabeb6 Require AWS_BUCKETNAME for prod, integration and labs environments only
AWS_BUCKETNAME is only needed in order to write on the bucket, but
read-only access should be allowed for other environments.

Fixes bug introduced by 6c3b610610
2020-03-05 09:56:09 +01:00
Akim Juillerat 99bf5ffef1 Merge pull request #151 from yvaucher/13.0-aws-bucketname-unstructured
[13.0] Add AWS_BUCKETNAME_UNSTRUCTURED to by-pass check
2020-03-05 09:53:36 +01:00
Patrick Tombez c4691d05a0 Merge pull request #142 from smussie/BSCLOUDFR-6
[13.0] Use keystoneauth v3 for Swift attachments
2020-03-04 10:23:00 +01:00
Mussie Sirak 426d7cbe87 Use keystoneauth v3 for Swift attachments 2020-03-04 10:17:02 +01:00
Yannick Vaucher feb737cb25 Swift same by-pass structured store location 2020-02-25 16:28:35 +01:00
Yannick Vaucher 6f66af94ab Add AWS_BUCKETNAME_UNSTRUCTURED to by-pass check
Curently the name of the bucket is cross checked with the
running environment. In rare case you can have a bucket name
that doesn't match the structure <project>-odoo-<env> in place.
2020-02-25 16:28:35 +01:00
Simone Orsi 8a1a78fe8e Merge pull request #136 from camptocamp/fixes
cloud_platform: fix default config
2020-02-04 13:39:11 +01:00
Simone Orsi ec6f8ee541 cloud_platform: fix default config
`_config_by_server_env` should always retutn a `PlatformConfig` instance
2020-02-04 11:42:35 +01:00
Patrick Tombez 7d3b359e3f Merge pull request #129 from p-tombez/13.0-anon_redis_session
Add anonymous redis session expiration configuration
2020-01-29 16:27:48 +01:00
Patrick Tombez 5fcef3926f Add anonymous redis session expiration configuration 2020-01-27 15:56:22 +01:00
Guewen Baconnier 20c0138588 Merge pull request #126 from sbidoul/patch-1
[FIX] logging_json: PyPI package as python external dep
2020-01-14 16:17:51 +01:00
Stéphane Bidoul (ACSONE) 24675ae14c [FIX] logging_json: PyPI package as python external dep 2019-12-21 15:03:35 +01:00
Vincent Renaville 7276de9cf0 Merge pull request #123 from vrenaville/fix_attachment_result
[13.0] Add method to force storage of special attachments to DB
2019-12-20 13:54:46 +01:00
Guewen Baconnier 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
Yannick Vaucher b083eaf63b Merge pull request #118 from leemannd/description_added
[13.0] Add description to model
2019-12-10 10:59:09 +01:00
Denis Leemann 07f7b3b19f Add description to model
This removes the useless warning at startup
2019-12-09 15:06:55 +01:00
Vincent Renaville d6b0c59488 Merge pull request #115 from vrenaville/imp_db_storage
[IMP] route file to db base on size and mimetype
2019-12-05 13:54:17 +01:00
vrenaville 29e6271a70 [IMP] route file to db base on size and mimetype 2019-12-05 09:34:23 +01:00
Vincent Renaville 3726b264ba Merge pull request #93 from Tonow-c2c/BSRD-286_MIG-13.0_cloud_platform_ovh
BSRD-286: MIG V13 cloud_platform_ovh
2019-12-03 14:02:02 +01:00
Vincent Renaville 8f023ce2f0 Merge pull request #86 from Tonow-c2c/BSRD-286_MIG-13.0_base_fileurl_field
BSRD-286: MIG V13 base_fileurl_field
2019-12-03 14:01:34 +01:00
Tonow-c2c 3a0492182f Merge pull request #85 from Tonow-c2c/BSRD-286_MIG-13.0_attachment_swift
Bsrd 286 mig 13.0 attachment swift
2019-12-03 11:47:12 +01:00
Tonow-c2c 7d0889750f BSRD-286: MIG V13 cloud_platform_ovh 2019-12-03 11:45:36 +01:00
Tonow-c2c 65cdd3dd64 BSRD-286: MIG V13 base_fileurl_field 2019-12-03 11:44:23 +01:00
Tonow-c2c be6a79fa87 BSRD-286: MIG V13 attachement_swift 2019-12-03 10:51:59 +01:00
Guewen Baconnier 3cb8ce8b8b Merge pull request #113 from guewen/13.0-add-support-running-env-labs
[13.0] Add support of 'labs' RUNNING_ENV in cloud_platform
2019-11-29 15:52:23 +01:00
Guewen Baconnier d9307f44cb Add an advice in error message 2019-11-18 16:25:34 +01:00
Guewen Baconnier a482f186ce Add support of 'labs' RUNNING_ENV in cloud_platform
The labs env can be anything starting by 'labs', such as
'labs-logistics', 'labs-finance', ...

* At install, s3/swift is set as default storage
* However, unlike prod/integration, the storage is not forced to be an
object storage
* Redis is required
* When the storage is set on s3/swift, then the bucket name is mandatory
(otherwise, there is no place where to create the files...)

The redis prefix regex match is relaxed: anything starting by a project
name, then '-odoo-', then any combination of letters, digits, and dashes
is accepted (so a prefix my-project9-odoo-labs-web3 is valid).
2019-11-18 16:25:34 +01:00
Guewen Baconnier 7684760065 Merge pull request #106 from camptocamp/revert-101-13.0-monitoring_check_db_connection
Revert "[13.0] [IMP] monitoring_status: check the db is reachable"
2019-11-18 14:45:09 +01:00
Guewen Baconnier bb0d50418e Use python3.6 2019-11-18 13:59:58 +01:00
Tonow-c2c 47f80319f9 Merge pull request #90 from Tonow-c2c/BSRD-286_MIG-13.0_monitoring_statsd
BSRD-286: MIG V13 monitoring_statsd
2019-11-08 14:33:26 +01:00