Skip to content

Commit

Permalink
[REF] deal with stream on base_attachment_object_storage
Browse files Browse the repository at this point in the history
  • Loading branch information
jjscarafia committed Dec 24, 2022
1 parent 9e38e3a commit ca15334
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 66 deletions.
1 change: 0 additions & 1 deletion attachment_s3/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

from . import models
65 changes: 0 additions & 65 deletions attachment_s3/models/ir_binary.py

This file was deleted.

24 changes: 24 additions & 0 deletions base_attachment_object_storage/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
from . import models
from odoo.http import Stream


old_from_attachment = Stream.from_attachment


@classmethod
def from_attachment(cls, attachment):
if attachment.store_fname and attachment._is_file_from_a_store(attachment.store_fname):
self = cls(
mimetype=attachment.mimetype,
download_name=attachment.name,
conditional=True,
etag=attachment.checksum,
)
self.type = 'data'
self.data = attachment.raw
self.last_modified = attachment['__last_update']
self.size = len(self.data)
return self
return old_from_attachment(attachment)


Stream.from_attachment = from_attachment

0 comments on commit ca15334

Please sign in to comment.