openerp-dev-web team mailing list archive
-
openerp-dev-web team
-
Mailing list archive
-
Message #04797
lp:~openerp-dev/openobject-addons/6.0-opw_document_content_4586-ach into lp:openobject-addons/6.0
Anup(OpenERP) has proposed merging lp:~openerp-dev/openobject-addons/6.0-opw_document_content_4586-ach into lp:openobject-addons/6.0.
Requested reviews:
Jay Vora (OpenERP) (jvo-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw_document_content_4586-ach/+merge/55478
Hello,
On installing the document module the old attachments were loosing the file content. Actually it was not being displayed due to the absence of file_size.
I have found a solution for fixing the issue. Please check it and share your views.
Thanks.
--
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw_document_content_4586-ach/+merge/55478
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/6.0-opw_document_content_4586-ach.
=== modified file 'document/document.py'
--- document/document.py 2011-02-18 14:10:12 +0000
+++ document/document.py 2011-03-30 07:11:26 +0000
@@ -49,6 +49,7 @@
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,6 +63,11 @@
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('SELECT id, db_datas FROM ir_attachment WHERE file_size=0')
+ old_attachments = cr.dictfetchall()
+ for attachment in old_attachments:
+ f_size = attachment['db_datas'].__len__()
+ cr.execute('UPDATE ir_attachment SET file_size=%s WHERE id=%s',(f_size,attachment['id']))
cr.execute("ALTER TABLE ir_attachment ALTER parent_id SET NOT NULL")
return True
Follow ups