تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2860 أدوات العرض

Hi, I want to put file (.xlsx) in field (binary) to test my function.

# model
    file = fields.Binary(string="File to import")

# test
    binary = open(modules.get_module_resource('import_stock', 'static/description/test.xlsx'), 'r')
    out = binary.read()
    self.import = self.env['file.import'].create({
        'name': 'test.xlsx',
        'file': out,
        'field': 'default_code',
        'column_lot': 2,
        'column_ref': 2,
        })

# my operation

    wb = load_workbook(BytesIO(base64.decodestring(self.file)))
    ws = wb.active


Error:
TypeError: expected bytes-like object, not NoneType

When I test on production (odoo UI), I have no error, but I want to test and I can't upload a file in python...
Thanks !
الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
أبريل 24
1390
1
أغسطس 20
2059
1
يونيو 25
222
0
مايو 25
440
2
أبريل 25
2560