[IMP] ir.attachment: active db storage by setting setting to "db"

bzr revid: chs@openerp.com-20140116224058-v53fozipvi0obmq1
This commit is contained in:
Christophe Simonis 2014-01-16 23:40:58 +01:00
parent 895b3c96f6
commit c55079f112
2 changed files with 4 additions and 4 deletions

View File

@ -138,7 +138,7 @@ class ir_attachment(osv.osv):
location = self._storage(cr, uid, context)
bin_size = context.get('bin_size')
for attach in self.browse(cr, uid, ids, context=context):
if location and attach.store_fname:
if location != 'db' and attach.store_fname:
result[attach.id] = self._file_read(cr, uid, location, attach.store_fname, bin_size)
else:
result[attach.id] = attach.db_datas
@ -152,7 +152,7 @@ class ir_attachment(osv.osv):
context = {}
location = self._storage(cr, uid, context)
file_size = len(value.decode('base64'))
if location:
if location != 'db':
attach = self.browse(cr, uid, id, context=context)
if attach.store_fname:
self._file_delete(cr, uid, location, attach.store_fname)
@ -299,7 +299,7 @@ class ir_attachment(osv.osv):
ids = [ids]
self.check(cr, uid, ids, 'unlink', context=context)
location = self._storage(cr, uid, context)
if location:
if location != 'db':
for attach in self.browse(cr, uid, ids, context=context):
if attach.store_fname:
self._file_delete(cr, uid, location, attach.store_fname)

View File

@ -27,7 +27,7 @@ class test_ir_attachment(openerp.tests.common.TransactionCase):
registry, cr, uid = self.registry, self.cr, self.uid
# force storing in database
registry('ir.config_parameter').set_param(cr, uid, 'ir_attachment.location', '')
registry('ir.config_parameter').set_param(cr, uid, 'ir_attachment.location', 'db')
# 'ir_attachment.location' is undefined test database storage
a1 = self.ira.create(cr, uid, {'name': 'a1', 'datas': self.blob1_b64})