diff --git a/product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.File.py b/product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.File.py
index 337c0bdf68d6f0e21f25b55592a1a13bf7175c93..ca90a7b54c9f550f71c988d5a2f32bd6554bd4a7 100644
--- a/product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.File.py
+++ b/product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.File.py
@@ -27,6 +27,7 @@
 #
 ##############################################################################
 
+import six
 from AccessControl import ClassSecurityInfo
 from Products.ERP5Type.Base import WorkflowMethod
 from Products.ERP5Type import Permissions, PropertySheet
@@ -150,6 +151,12 @@ class File(Document, OFS_File):
       data.seek(0)
       self.manage_upload(data)
 
+  security.declarePrivate('update_data')
+  def update_data(self, *args, **kw):
+    super(File, self).update_data(*args, **kw)
+    if six.PY2 and isinstance(self.size, long):
+      self.size = int(self.size)
+
   security.declareProtected(Permissions.ModifyPortalContent,'setFile')
   def setFile(self, data, precondition=None):
     self._setFile(data, precondition=precondition)