summaryrefslogtreecommitdiff
path: root/addons/document/document.py
diff options
context:
space:
mode:
authorJay Vora (OpenERP) <jvo@tinyerp.com>2011-04-01 14:47:21 +0530
committerJay Vora (OpenERP) <jvo@tinyerp.com>2011-04-01 14:47:21 +0530
commit5bb62f86be90ec74b8a163978ed5b9c04d8e3f6e (patch)
treef17ec87abe2a42ce1209159f6fa2542e48c6550e /addons/document/document.py
parent9e3f4506abac4d446e5736963bc18f3618ba9736 (diff)
parent091d78558664543f38c0697a5b06886f0b002bcf (diff)
[MERGE] Merged Anup's branch for the fix of documents' file_size.
bzr revid: jvo@tinyerp.com-20110401091721-bs0167iw9p7ykx8s
Diffstat (limited to 'addons/document/document.py')
-rw-r--r--addons/document/document.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/addons/document/document.py b/addons/document/document.py
index 1a553b23ed1..72012316d25 100644
--- a/addons/document/document.py
+++ b/addons/document/document.py
@@ -49,6 +49,7 @@ class document_file(osv.osv):
It also establishes the parent_id NOT NULL constraint that ir.attachment
should have had (but would have failed if plain attachments contained null
values).
+ It also updates the File Size for the previously created attachments.
"""
parent_id = self.pool.get('document.directory')._get_root_directory(cr,uid)
@@ -62,7 +63,17 @@ class document_file(osv.osv):
cr.execute("UPDATE ir_attachment " \
"SET parent_id = %s, db_datas = decode(encode(db_datas,'escape'), 'base64') " \
"WHERE parent_id IS NULL", (parent_id,))
+
cr.execute("ALTER TABLE ir_attachment ALTER parent_id SET NOT NULL")
+
+ #Proceeding to update the filesize of the corresponsing attachment
+ cr.execute('SELECT id, db_datas FROM ir_attachment WHERE file_size=0')
+ old_attachments = cr.dictfetchall()
+
+ for attachment in old_attachments:
+ f_size = len(attachment['db_datas'])
+ cr.execute('UPDATE ir_attachment SET file_size=%s WHERE id=%s',(f_size,attachment['id']))
+
return True
def _get_filestore(self, cr):