Skip to Content
Menu
This question has been flagged

Hey ..

i got those errors after clicking on validate button .

  • Unknown error during import: <type 'exceptions.TypeError'>: sequence item 0: expected string, bool found at row 2

  • Unknown error during import: <type 'exceptions.TypeError'>: sequence item 0: expected string, int found at row 11


i'm trying to override the write method so i can store images in filestore instead of database so when i click on validate button in import forum i got those errors above


here is my code [ i'm testing it using logo only] :


def write(self, cr, uid, ids, vals, context=None):
for survey in self.browse(cr, uid, ids, context=context):
print "survey id", survey.id
photos = {
'logo': survey.image_logo_attachment_id.id,
'photo1': survey.image_photo1_attachment_id.id,
'photo2': survey.image_photo2_attachment_id.id,
'photo3': survey.image_photo3_attachment_id.id,
'photo4': survey.image_photo4_attachment_id.id,
'photo5': survey.image_photo5_attachment_id.id
}
photo_name = 'logo'
# for photo_name in ['logo','photo1','photo2','photo3','photo4','photo5']:
if vals.has_key(photo_name) and vals.get(photo_name):
image_id = photos.get(photo_name)
attachment_id_key = 'image_%s_attachment_id' % photo_name
# image_id_key = vals.get(photo_name)

if not vals.get(photo_name):
ids = [attach_id for attach_id in [image_id] if attach_id]
if ids:
self.pool['ir.attachment'].unlink(cr, uid, ids, context=context)
return True
if not (image_id):
image_id = self.pool['ir.attachment'].create(cr, uid, {'name': 'Survey %d-%s.png' % (survey.id, survey.name)},
context=context)
self.write(cr, uid, survey.id, {attachment_id_key: image_id}, context=context)

image_photo = zoser_image_tool.image_resize_image_photo(vals.get(photo_name))
self.pool['ir.attachment'].write(cr, uid, image_id, {'datas': image_photo}, context=context)

vals[photos[photo_name]] = image_photo
 
 

return super(yext_survey, self).write(cr, uid, ids, vals, context=context)


Avatar
Discard
Author Best Answer

Any one  :D ?


Avatar
Discard
Related Posts Replies Views Activity
3
Nov 21
16197
0
Jun 19
3953
2
Feb 23
6261
5
Oct 24
26730
0
Sep 20
2234