From ba53d85a07a36040a4110a01db6c9c1d7ed6043e Mon Sep 17 00:00:00 2001 From: Albert Cervera i Areny <> Date: Mon, 26 Oct 2009 21:08:17 +0530 Subject: [FIX] Document : Attachment with document can now be deleted lp bug: https://launchpad.net/bugs/460701 fixed bzr revid: jvo@tinyerp.com-20091026153817-cn3mmj43ng90ymyp --- addons/document/document.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'addons/document/document.py') diff --git a/addons/document/document.py b/addons/document/document.py index 460c52a9698..338c6e69255 100644 --- a/addons/document/document.py +++ b/addons/document/document.py @@ -531,17 +531,21 @@ class document_file(osv.osv): result[id] = base64.encodestring(value) except: result[id]='' - - if context.get('bin_size', False): - result[id] = tools.human_size(len(result[id])) - +# if context.get('bin_size', False): +# result[id] = tools.human_size(result[id]) return result # # This code can be improved # - def _data_set(self, cr, obj, id, name, value, uid=None, context={}): + def _data_set(self, cr, uid, id, name, value, args=None, context={}): if not value: + filename = self.browse(cr, uid, id, context).store_fname + try: + os.unlink(os.path.join(self._get_filestore(cr), filename)) + except: + pass + cr.execute('update ir_attachment set store_fname=NULL WHERE id=%s', (id,) ) return True #if (not context) or context.get('store_method','fs')=='fs': try: -- cgit v1.2.3