From a7e364f93b2e2e76e1e2157fe2bbf47d95ce0c87 Mon Sep 17 00:00:00 2001 From: Akim Juillerat Date: Mon, 7 Oct 2019 13:33:53 +0200 Subject: [PATCH] [MIG] base_attachment_object_storage: Migration to 13.0 --- base_attachment_object_storage/__manifest__.py | 6 +++--- .../models/ir_attachment.py | 16 ++++++---------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/base_attachment_object_storage/__manifest__.py b/base_attachment_object_storage/__manifest__.py index b6a3fcb..ed66fea 100644 --- a/base_attachment_object_storage/__manifest__.py +++ b/base_attachment_object_storage/__manifest__.py @@ -1,16 +1,16 @@ -# Copyright 2017-2018 Camptocamp SA +# Copyright 2017-2019 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) {'name': 'Base Attachment Object Store', 'summary': 'Base module for the implementation of external object store.', - 'version': '12.0.1.1.0', + 'version': '13.0.1.1.0', 'author': 'Camptocamp,Odoo Community Association (OCA)', 'license': 'AGPL-3', 'category': 'Knowledge Management', 'depends': ['base'], 'website': 'http://www.camptocamp.com', 'data': [], - '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 85296c8..0caa39a 100644 --- a/base_attachment_object_storage/models/ir_attachment.py +++ b/base_attachment_object_storage/models/ir_attachment.py @@ -1,4 +1,4 @@ -# Copyright 2017-2018 Camptocamp SA +# Copyright 2017-2019 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) import base64 @@ -39,9 +39,8 @@ class IrAttachment(models.Model): _local_fields = ('image_small', 'image_medium', 'web_icon_data') - @api.cr def _register_hook(self): - super(IrAttachment, self)._register_hook() + super()._register_hook() location = self.env.context.get('storage_location') or self._storage() # ignore if we are not using an object storage if location not in self._get_stores(): @@ -67,7 +66,6 @@ class IrAttachment(models.Model): if update_module: self.env['ir.attachment'].sudo()._force_storage_to_object_storage() - @api.multi def _save_in_db_anyway(self): """ Return whether an attachment must be stored in db @@ -131,8 +129,7 @@ class IrAttachment(models.Model): if self._is_file_from_a_store(fname): return self._store_file_read(fname, bin_size=bin_size) else: - _super = super(IrAttachment, self) - return _super._file_read(fname, bin_size=bin_size) + return super()._file_read(fname, bin_size=bin_size) def _store_file_read(self, fname, bin_size=False): storage = fname.partition('://')[0] @@ -161,7 +158,7 @@ class IrAttachment(models.Model): key = self._compute_checksum(bin_data) filename = self._store_file_write(key, bin_data) else: - filename = super(IrAttachment, self)._file_write(value, checksum) + filename = super()._file_write(value, checksum) return filename @api.model @@ -176,7 +173,7 @@ class IrAttachment(models.Model): if not count: self._store_file_delete(fname) else: - super(IrAttachment, self)._file_delete(fname) + super()._file_delete(fname) @api.model def _is_file_from_a_store(self, fname): @@ -211,7 +208,6 @@ class IrAttachment(models.Model): # make a copy yield self.env() - @api.multi def _move_attachment_to_store(self): self.ensure_one() _logger.info('inspecting attachment %s (%d)', self.name, self.id) @@ -239,7 +235,7 @@ class IrAttachment(models.Model): _('Only administrators can execute this action.')) location = self.env.context.get('storage_location') or self._storage() if location not in self._get_stores(): - return super(IrAttachment, self).force_storage() + return super().force_storage() self._force_storage_to_object_storage() @api.model