Skip to content

Commit

Permalink
fix(attachment_s3): partition fn property
Browse files Browse the repository at this point in the history
  • Loading branch information
dnplkndll committed Aug 3, 2022
1 parent fd56983 commit fc303c0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion attachment_s3/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
'python': ['boto3'],
},
'website': 'https://www.camptocamp.com',
'data': [],
'data': ['data/res_config_settings_data.xml'],
'installable': True,
}
9 changes: 9 additions & 0 deletions attachment_s3/data/res_config_settings_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version='1.0' encoding='utf-8'?>
<odoo noupdate="1">

<record id="ir_attachment_storage_partition" model="ir.config_parameter">
<field name="key">ir_attachment.storage.partition</field>
<field name="value">%Y-%m</field>
</record>

</odoo>
4 changes: 3 additions & 1 deletion attachment_s3/models/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ def _store_file_read(self, fname):
@api.model
def _store_file_write(self, key, bin_data):
location = self.env.context.get('storage_location') or self._storage()
partition = self.env.context.get('storage_partition') or "%Y-%m"
partition = self.env['ir.config_parameter'].sudo().get_param(
'ir_attachment.storage.partition',
)
if location == 's3':
bucket = self._get_s3_bucket()
obj = bucket.Object(key=key)
Expand Down

0 comments on commit fc303c0

Please sign in to comment.