mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-24 08:47:40 +00:00
Merge pull request #64 from tschanzt/fix_inverse_datas
Fix inverse datas for swift storage
This commit is contained in:
@@ -90,7 +90,7 @@ class IrAttachment(models.Model):
|
|||||||
if fname:
|
if fname:
|
||||||
self._file_delete(fname)
|
self._file_delete(fname)
|
||||||
continue
|
continue
|
||||||
self._data_set('datas', attach.datas, None)
|
attach._data_set('datas', attach.datas, None)
|
||||||
|
|
||||||
def _register_hook(self, cr):
|
def _register_hook(self, cr):
|
||||||
super(IrAttachment, self)._register_hook(cr)
|
super(IrAttachment, self)._register_hook(cr)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import psycopg2
|
|||||||
import odoo
|
import odoo
|
||||||
|
|
||||||
from contextlib import closing, contextmanager
|
from contextlib import closing, contextmanager
|
||||||
from openerp import api, exceptions, models, _
|
from openerp import api, exceptions, fields, models, _
|
||||||
from openerp import SUPERUSER_ID
|
from openerp import SUPERUSER_ID
|
||||||
|
|
||||||
|
|
||||||
@@ -40,6 +40,19 @@ class IrAttachment(models.Model):
|
|||||||
|
|
||||||
_local_fields = ('image_small', 'image_medium', 'web_icon_data')
|
_local_fields = ('image_small', 'image_medium', 'web_icon_data')
|
||||||
|
|
||||||
|
datas = fields.Binary(
|
||||||
|
compute='_compute_datas',
|
||||||
|
inverse='_inverse_datas',
|
||||||
|
string='File Content',
|
||||||
|
nodrop=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
@api.depends('store_fname', 'db_datas')
|
||||||
|
def _compute_datas(self):
|
||||||
|
values = self._data_get('datas', None)
|
||||||
|
for attach in self:
|
||||||
|
attach.datas = values.get(attach.id)
|
||||||
|
|
||||||
@api.cr
|
@api.cr
|
||||||
def _register_hook(self, cr):
|
def _register_hook(self, cr):
|
||||||
super(IrAttachment, self)._register_hook(cr)
|
super(IrAttachment, self)._register_hook(cr)
|
||||||
@@ -128,7 +141,7 @@ class IrAttachment(models.Model):
|
|||||||
if fname:
|
if fname:
|
||||||
self._file_delete(fname)
|
self._file_delete(fname)
|
||||||
continue
|
continue
|
||||||
super(IrAttachment, attach)._inverse_datas()
|
attach._data_set('datas', attach.datas, None)
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _file_read(self, fname, bin_size=False):
|
def _file_read(self, fname, bin_size=False):
|
||||||
|
|||||||
Reference in New Issue
Block a user