mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-23 18:04:34 +00:00
[MIG] base_attachment_object_storage: Migration to 14.0
This commit is contained in:
@@ -4,13 +4,13 @@
|
|||||||
|
|
||||||
{'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': '13.0.1.1.0',
|
'version': "14.0.1.0.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/res_config_settings_data.xml'],
|
'data': ['data/res_config_settings_data.xml'],
|
||||||
'installable': False,
|
'installable': True,
|
||||||
'auto_install': True,
|
'auto_install': True,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,13 +178,13 @@ class IrAttachment(models.Model):
|
|||||||
return super()._get_datas_related_values(data, mimetype)
|
return super()._get_datas_related_values(data, mimetype)
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _file_read(self, fname, bin_size=False):
|
def _file_read(self, fname):
|
||||||
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)
|
||||||
else:
|
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]
|
storage = fname.partition('://')[0]
|
||||||
raise NotImplementedError(
|
raise NotImplementedError(
|
||||||
'No implementation for %s' % (storage,)
|
'No implementation for %s' % (storage,)
|
||||||
@@ -202,16 +202,15 @@ class IrAttachment(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@api.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()
|
location = self.env.context.get('storage_location') or self._storage()
|
||||||
if location in self._get_stores():
|
if location in self._get_stores():
|
||||||
bin_data = base64.b64decode(value)
|
|
||||||
key = self.env.context.get('force_storage_key')
|
key = self.env.context.get('force_storage_key')
|
||||||
if not key:
|
if not key:
|
||||||
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()._file_write(value, checksum)
|
filename = super()._file_write(bin_data, checksum)
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
|
|||||||
Reference in New Issue
Block a user