From 4d665d96c166e22174bc5bbdc3fae69cac642e5d Mon Sep 17 00:00:00 2001 From: Patrick Tombez Date: Tue, 3 Nov 2020 11:36:50 +0100 Subject: [PATCH] [MIG] base_attachment_object_storage: Migration to 14.0 --- base_attachment_object_storage/__manifest__.py | 4 ++-- .../models/ir_attachment.py | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/base_attachment_object_storage/__manifest__.py b/base_attachment_object_storage/__manifest__.py index d2b5777..e410519 100644 --- a/base_attachment_object_storage/__manifest__.py +++ b/base_attachment_object_storage/__manifest__.py @@ -4,13 +4,13 @@ {'name': 'Base Attachment Object Store', 'summary': 'Base module for the implementation of external object store.', - 'version': '13.0.1.1.0', + 'version': "14.0.1.0.0", 'author': 'Camptocamp,Odoo Community Association (OCA)', 'license': 'AGPL-3', 'category': 'Knowledge Management', 'depends': ['base'], 'website': 'http://www.camptocamp.com', 'data': ['data/res_config_settings_data.xml'], - 'installable': False, + 'installable': True, 'auto_install': True, } diff --git a/base_attachment_object_storage/models/ir_attachment.py b/base_attachment_object_storage/models/ir_attachment.py index 260c6ca..cd26db6 100644 --- a/base_attachment_object_storage/models/ir_attachment.py +++ b/base_attachment_object_storage/models/ir_attachment.py @@ -178,13 +178,13 @@ class IrAttachment(models.Model): return super()._get_datas_related_values(data, mimetype) @api.model - def _file_read(self, fname, bin_size=False): + def _file_read(self, fname): if self._is_file_from_a_store(fname): - return self._store_file_read(fname, bin_size=bin_size) + return self._store_file_read(fname) else: - return super()._file_read(fname, bin_size=bin_size) + return super()._file_read(fname) - def _store_file_read(self, fname, bin_size=False): + def _store_file_read(self, fname): storage = fname.partition('://')[0] raise NotImplementedError( 'No implementation for %s' % (storage,) @@ -202,16 +202,15 @@ class IrAttachment(models.Model): ) @api.model - def _file_write(self, value, checksum): + def _file_write(self, bin_data, checksum): location = self.env.context.get('storage_location') or self._storage() if location in self._get_stores(): - bin_data = base64.b64decode(value) key = self.env.context.get('force_storage_key') if not key: key = self._compute_checksum(bin_data) filename = self._store_file_write(key, bin_data) else: - filename = super()._file_write(value, checksum) + filename = super()._file_write(bin_data, checksum) return filename @api.model