跳至内容
菜单
此问题已终结

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)


形象
丢弃
编写者 最佳答案

Any one  :D ?


形象
丢弃
相关帖文 回复 查看 活动
3
11月 21
18363
0
6月 19
5024
2
2月 23
8062
5
10月 24
29024
0
9月 20
3295