diff --git a/openerp/addons/base/ir/ir_attachment.py b/openerp/addons/base/ir/ir_attachment.py index 85770669aac..ca61fb46fc7 100644 --- a/openerp/addons/base/ir/ir_attachment.py +++ b/openerp/addons/base/ir/ir_attachment.py @@ -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) diff --git a/openerp/addons/base/tests/test_ir_attachment.py b/openerp/addons/base/tests/test_ir_attachment.py index 9c02ce6265f..a5e546a90c4 100644 --- a/openerp/addons/base/tests/test_ir_attachment.py +++ b/openerp/addons/base/tests/test_ir_attachment.py @@ -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})