compta_file.close()
fp = BytesIO()
# workbook.save(fp)
attach_id = self.env['ir.attachment'].sudo().create(
{'name': self.writing_file_transfer+ str(self.id) + '.csv', 'type': 'binary', 'public': True,
'datas': base64.encodebytes(fp.getvalue()), })
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- إدارة علاقات العملاء
- e-Commerce
- المحاسبة
- المخزون
- PoS
- Project
- MRP
لقد تم الإبلاغ عن هذا السؤال
Hi,
In Odoo, if a field (like self.writing_file_transfer) has no value set, it defaults to False, which is a boolean. When Python reaches the line
self.writing_file_transfer + str(self.id) + '.csv'
It tries to do False + "123.csv", but Python cannot add a boolean to a string, so it raises TypeError. In other words, the error is not because the code itself is wrong, but because the field has no value (so it became False) and Python doesn’t know how to concatenate False with text. To fix this, you must explicitly handle the case when the field is empty, e.g. str(self.writing_file_transfer or ''), so it uses an empty string instead of False.
Hope it helps.
Hello Gowtham A,
I hope you're doing well.
The error occurs because self.writing_file_transfer is a boolean (True or False), and you're trying to concatenate it with a string (str(self.id) + '.csv'). Since Python does not allow direct concatenation of a boolean and a string, it raises a TypeError.
Convert self.writing_file_transfer to a string before concatenation:
{'name': str(self.writing_file_transfer) + str(self.id) + '.csv', 'type': 'binary', 'public': True,
'datas': base64.encodebytes(fp.getvalue()), }
I hope this resolves your issue.
Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari
if you check type of
self.writing_file_transfer
its may Boolean and you are trying to add Boolean and string
try this :
str(self.writing_file_transfer)
هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!
أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!
تسجيلالمنشورات ذات الصلة | الردود | أدوات العرض | النشاط | |
---|---|---|---|---|
|
0
مايو 24
|
1622 | ||
|
1
أغسطس 22
|
2538 | ||
|
2
أغسطس 25
|
356 | ||
|
1
أغسطس 25
|
274 | ||
|
2
أغسطس 25
|
1832 |