Merge pull request #9 from vrenaville/delivery_carrier_label_s3

[FIX] call method on attachement_id instead of self
This commit is contained in:
Vincent Renaville
2017-02-15 19:01:37 +01:00
committed by GitHub
co-authored by GitHub
@@ -17,7 +17,7 @@ class ShippingLabel(models.Model):
@api.depends('store_fname', 'db_datas')
def _compute_datas(self):
values = self._data_get('datas', None)
values = self.attachment_id._data_get('datas', None)
for attach in self:
attach.datas = values.get(attach.id)
@@ -26,13 +26,13 @@ class ShippingLabel(models.Model):
# we keep them in the database instead of the object storage
location = self.attachment_id._storage()
for attach in self:
if location == 's3' and self._store_in_db_when_s3():
if location == 's3' and self.attachment_id._store_in_db_when_s3():
# compute the fields that depend on datas
value = attach.datas
bin_data = value and value.decode('base64') or ''
vals = {
'file_size': len(bin_data),
'checksum': self._compute_checksum(bin_data),
'checksum': self.attachment_id._compute_checksum(bin_data),
'db_datas': value,
# we seriously don't need index content on those fields
'index_content': False,
@@ -43,6 +43,6 @@ class ShippingLabel(models.Model):
# have write access
super(ShippingLabel, attach.sudo()).write(vals)
if fname:
self._file_delete(fname)
self.attachment_id._file_delete(fname)
continue
self.attachment_id._data_set('datas', attach.datas, None)