mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-24 08:47:40 +00:00
Merge commit 'refs/pull/83/head' of github.com:camptocamp/odoo-cloud-platform into merge-branch-2762-BSRD-286_Check_odoo-cloud-platform-32273415
This commit is contained in:
@@ -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)
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||||
|
|
||||||
|
|
||||||
{'name': 'Base Attachment Object Store',
|
{'name': 'Base Attachment Object Store',
|
||||||
'summary': 'Base module for the implementation of external 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)',
|
'author': 'Camptocamp,Odoo Community Association (OCA)',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'category': 'Knowledge Management',
|
'category': 'Knowledge Management',
|
||||||
'depends': ['base'],
|
'depends': ['base'],
|
||||||
'website': 'http://www.camptocamp.com',
|
'website': 'http://www.camptocamp.com',
|
||||||
'data': [],
|
'data': [],
|
||||||
'installable': False,
|
'installable': True,
|
||||||
'auto_install': True,
|
'auto_install': True,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
@@ -39,9 +39,8 @@ class IrAttachment(models.Model):
|
|||||||
|
|
||||||
_local_fields = ('image_small', 'image_medium', 'web_icon_data')
|
_local_fields = ('image_small', 'image_medium', 'web_icon_data')
|
||||||
|
|
||||||
@api.cr
|
|
||||||
def _register_hook(self):
|
def _register_hook(self):
|
||||||
super(IrAttachment, self)._register_hook()
|
super()._register_hook()
|
||||||
location = self.env.context.get('storage_location') or self._storage()
|
location = self.env.context.get('storage_location') or self._storage()
|
||||||
# ignore if we are not using an object storage
|
# ignore if we are not using an object storage
|
||||||
if location not in self._get_stores():
|
if location not in self._get_stores():
|
||||||
@@ -67,7 +66,6 @@ class IrAttachment(models.Model):
|
|||||||
if update_module:
|
if update_module:
|
||||||
self.env['ir.attachment'].sudo()._force_storage_to_object_storage()
|
self.env['ir.attachment'].sudo()._force_storage_to_object_storage()
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _save_in_db_anyway(self):
|
def _save_in_db_anyway(self):
|
||||||
""" Return whether an attachment must be stored in db
|
""" 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):
|
if self._is_file_from_a_store(fname):
|
||||||
return self._store_file_read(fname, bin_size=bin_size)
|
return self._store_file_read(fname, bin_size=bin_size)
|
||||||
else:
|
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):
|
def _store_file_read(self, fname, bin_size=False):
|
||||||
storage = fname.partition('://')[0]
|
storage = fname.partition('://')[0]
|
||||||
@@ -161,7 +158,7 @@ class IrAttachment(models.Model):
|
|||||||
key = self._compute_checksum(bin_data)
|
key = self._compute_checksum(bin_data)
|
||||||
filename = self._store_file_write(key, bin_data)
|
filename = self._store_file_write(key, bin_data)
|
||||||
else:
|
else:
|
||||||
filename = super(IrAttachment, self)._file_write(value, checksum)
|
filename = super()._file_write(value, checksum)
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
@@ -176,7 +173,7 @@ class IrAttachment(models.Model):
|
|||||||
if not count:
|
if not count:
|
||||||
self._store_file_delete(fname)
|
self._store_file_delete(fname)
|
||||||
else:
|
else:
|
||||||
super(IrAttachment, self)._file_delete(fname)
|
super()._file_delete(fname)
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _is_file_from_a_store(self, fname):
|
def _is_file_from_a_store(self, fname):
|
||||||
@@ -211,7 +208,6 @@ class IrAttachment(models.Model):
|
|||||||
# make a copy
|
# make a copy
|
||||||
yield self.env()
|
yield self.env()
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _move_attachment_to_store(self):
|
def _move_attachment_to_store(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
_logger.info('inspecting attachment %s (%d)', self.name, self.id)
|
_logger.info('inspecting attachment %s (%d)', self.name, self.id)
|
||||||
@@ -239,7 +235,7 @@ class IrAttachment(models.Model):
|
|||||||
_('Only administrators can execute this action.'))
|
_('Only administrators can execute this action.'))
|
||||||
location = self.env.context.get('storage_location') or self._storage()
|
location = self.env.context.get('storage_location') or self._storage()
|
||||||
if location not in self._get_stores():
|
if location not in self._get_stores():
|
||||||
return super(IrAttachment, self).force_storage()
|
return super().force_storage()
|
||||||
self._force_storage_to_object_storage()
|
self._force_storage_to_object_storage()
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
|
|||||||
Reference in New Issue
Block a user