mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-24 08:47:40 +00:00
Merge commit 'refs/pull/121/head' of github.com:camptocamp/odoo-cloud-platform into merge-branch-2543-bssmb-274_fix_s3_pictures_issues-4920e064
This commit is contained in:
@@ -24,6 +24,8 @@ FileURL fields is intended to store Binary data on an external storage
|
|||||||
Will be used to set fname on ir.attachment and, if storage_path is
|
Will be used to set fname on ir.attachment and, if storage_path is
|
||||||
defined, will be passed to force the storage key.
|
defined, will be passed to force the storage key.
|
||||||
|
|
||||||
|
:param acl_public_read: Set public-read ACL by default
|
||||||
|
|
||||||
Limitations / Issues
|
Limitations / Issues
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class FileURL(fields.Binary):
|
|||||||
'storage_location': '', # External storage activated on the system (cf base_attachment_storage) # noqa
|
'storage_location': '', # External storage activated on the system (cf base_attachment_storage) # noqa
|
||||||
'storage_path': '', # Path to be used as storage key (prefix of filename) # noqa
|
'storage_path': '', # Path to be used as storage key (prefix of filename) # noqa
|
||||||
'filename': '', # Field to use to store the filename on ir.attachment
|
'filename': '', # Field to use to store the filename on ir.attachment
|
||||||
|
'acl_public_read': True, # Set public-read ACL by default
|
||||||
}
|
}
|
||||||
|
|
||||||
def create(self, record_values):
|
def create(self, record_values):
|
||||||
@@ -51,6 +52,7 @@ class FileURL(fields.Binary):
|
|||||||
'res_field': self.name,
|
'res_field': self.name,
|
||||||
'res_id': record.id,
|
'res_id': record.id,
|
||||||
'type': 'binary',
|
'type': 'binary',
|
||||||
|
'public': self.acl_public_read,
|
||||||
'datas': value,
|
'datas': value,
|
||||||
}
|
}
|
||||||
fname = False
|
fname = False
|
||||||
@@ -61,11 +63,13 @@ class FileURL(fields.Binary):
|
|||||||
storage_key = self._build_storage_key(fname)
|
storage_key = self._build_storage_key(fname)
|
||||||
if not fname:
|
if not fname:
|
||||||
storage_key = False
|
storage_key = False
|
||||||
env['ir.attachment'].sudo().with_context(
|
attachment = env['ir.attachment'].sudo().with_context(
|
||||||
binary_field_real_user=env.user,
|
binary_field_real_user=env.user,
|
||||||
storage_location=self.storage_location,
|
storage_location=self.storage_location,
|
||||||
force_storage_key=storage_key,
|
force_storage_key=storage_key,
|
||||||
).create(vals)
|
).create(vals)
|
||||||
|
if self.acl_public_read:
|
||||||
|
attachment._store_file_set_acl('public-read')
|
||||||
|
|
||||||
def write(self, records, value):
|
def write(self, records, value):
|
||||||
for record in records:
|
for record in records:
|
||||||
|
|||||||
Reference in New Issue
Block a user